Context
Copilot SDK session event envelopes can carry an optional agentId when emitted for a subagent. We hardened user.message handling so subagent messages do not mutate root steering/event-ID state or emit root-only instruction telemetry, and replay restores them in the subagent transcript.
The SDK exposes agentId across its event union. Audit the remaining Agent Host consumers for root-only assumptions and either route, ignore, or explicitly document each subagent event.
Events to review
Highest-risk state-mutating consumers:
system.notification: currently creates or appends root turns in live handling and replay.
session.idle: currently completes or aborts the root turn.
session.error: currently emits a root chat error.
session.auto_mode_resolved: currently updates root model and usage state.
assistant.intent: currently updates root session activity.
session.model_change: currently affects root replay model selection.
assistant.usage: an unmapped subagent event can currently fall back to root usage.
- MCP server, tool, and command inventory events: currently treated as session-global; verify whether subagent-scoped variants should be ignored or projected globally.
Logging-only and memo-invalidation listeners do not need guards unless their behavior gains stateful side effects.
Acceptance criteria
- Classify every consumed SDK event that may carry
agentId as session-global, root-only, or subagent-routed.
- Add explicit guards or routing for root-only and subagent-scoped behavior.
- Drop and warn for unmapped subagent events where ordering/correlation is required.
- Keep live handling and persisted-history replay behavior consistent.
- Add focused regression tests for each state-mutating path changed.
(Written by Copilot)
Context
Copilot SDK session event envelopes can carry an optional
agentIdwhen emitted for a subagent. We hardeneduser.messagehandling so subagent messages do not mutate root steering/event-ID state or emit root-only instruction telemetry, and replay restores them in the subagent transcript.The SDK exposes
agentIdacross its event union. Audit the remaining Agent Host consumers for root-only assumptions and either route, ignore, or explicitly document each subagent event.Events to review
Highest-risk state-mutating consumers:
system.notification: currently creates or appends root turns in live handling and replay.session.idle: currently completes or aborts the root turn.session.error: currently emits a root chat error.session.auto_mode_resolved: currently updates root model and usage state.assistant.intent: currently updates root session activity.session.model_change: currently affects root replay model selection.assistant.usage: an unmapped subagent event can currently fall back to root usage.Logging-only and memo-invalidation listeners do not need guards unless their behavior gains stateful side effects.
Acceptance criteria
agentIdas session-global, root-only, or subagent-routed.(Written by Copilot)