Skip to content

[remote-copilot-sdk] Surface remote SDK built-in tool events under the SDK session node (root sink placement) #1318

Description

@JoshuaRowePhantom

Part of #1313

Summary

Ensure that when the REMOTE CopilotSdkChatClient self-invokes its built-in shell/powershell tool (root AgentId == null), the resulting ToolExecutionStartEvent / ToolExecutionCompleteEvent pair survives the transport hop and, on the SOURCE, is written to the root/session sink (no ParentToolCallIdPropertyName) and appears as children of the SDK session node in AgentChat history — not lost, not attributed to a sub-agent.

This sub-item covers node hierarchy / placement + the assertion. It relies on #1312 (the CopilotSdkStreamAdapter switch dropping unmapped events, no default arm) being fixed so unknown/future kinds are not silently discarded.

Dependencies

Root Cause / Current State

Affected Files

Design / Fix

  1. Node hierarchy contract. For events with AgentId == null (root), the emitted ChatResponseUpdate MUST NOT carry CopilotSdkStreamAdapter.ParentToolCallIdPropertyName. Confirm this is already the behavior of the :113 / :121 mappings; add unit coverage that pins it. For events with a non-null AgentId (sub-agent), the property MUST be set so CopilotSubAgentRouter routes them.
  2. SDK session node placement. Root-tagged tool-execution items must land on the SDK session node's root sink so they render as children of that node in AgentChat history. Add coverage against CopilotSubAgentRouter that root items reach the root sink and are not attributed to any sub-agent.
  3. Drop-safety (via Copilot SDK adapter silently drops unhandled SDK session events (no default arm; self-invoke bypasses framework tool loop) #1312). Once Copilot SDK adapter silently drops unhandled SDK session events (no default arm; self-invoke bypasses framework tool loop) #1312 adds the default arm, add a unit test that an unknown/future SessionEvent subclass produces at least a diagnostic (not a silent drop). This sub-item does not itself change the adapter's switch; it consumes the fix.
  4. Out of scope: the transport hop and full source-side history assertion (covered by S6).

Expected Tests

Follow the Subject_Scenario_ExpectedOutcome convention. Mirror existing tests in features/Phantom.Workspaces.Llm.Core.Tests/CopilotSdkChatClientTests.cs (naming style) and any existing CopilotSdkStreamAdapterTests / CopilotSubAgentRouterTests.

Test Asserts
CopilotSdkStreamAdapter_ToolExecutionStartEventRootAgentId_EmitsUpdateWithoutParentToolCallIdProperty A ToolExecutionStartEvent with AgentId == null maps (at :113) to a ChatResponseUpdate that does NOT carry ParentToolCallIdPropertyName.
CopilotSdkStreamAdapter_ToolExecutionCompleteEventRootAgentId_EmitsUpdateWithoutParentToolCallIdProperty Same for ToolExecutionCompleteEvent at :121.
CopilotSdkStreamAdapter_ToolExecutionEventsWithAgentId_SetParentToolCallIdProperty Sub-agent-tagged events still carry the property (regression guard so #1312's fix doesn't over-strip).
CopilotSubAgentRouter_RootTaggedToolExecutionItems_RouteToRootSessionSink Given root-tagged items produced by the adapter, CopilotSubAgentRouter (:27-40) delivers them to the root/session sink, NOT to any sub-agent sink.
CopilotSubAgentRouter_SubAgentTaggedToolExecutionItems_RouteToMatchingSubAgentSink Sub-agent-tagged items route to the sink matching their ParentToolCallId (regression guard).
AgentChatHistory_RootShellToolExecutionItems_AppearAsChildrenOfSdkSessionNode End-of-turn AgentChat history places root shell/powershell tool-execution items as children of the SDK session node (structural assertion using the same in-memory AgentChat used in existing tests).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingdiagnosedRoot cause identifiedverified-locallyImplementation has been verified locally

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions