Skip to content

docs: document sub-agent event attribution#1878

Open
loganrosen wants to merge 10 commits into
github:mainfrom
loganrosen:loganrosen-improve-sdk-docs
Open

docs: document sub-agent event attribution#1878
loganrosen wants to merge 10 commits into
github:mainfrom
loganrosen:loganrosen-improve-sdk-docs

Conversation

@loganrosen

@loganrosen loganrosen commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR documents envelope-level agentId as the canonical way to attribute session events to sub-agent instances. The streaming events guide now explains how root/main-agent and session-level events omit agentId, while sub-agent-originated events include it, and shows parent-response filtering consistently across TypeScript, Python, Go, .NET, Java, and Rust.

To keep the Java SDK aligned with the documented contract, this also updates Java session event codegen so generated SessionEvent exposes agentId, then adds deserialization coverage for that envelope field. Payload-level parentToolCallId remains documented as deprecated rather than removed.

Validation

  • cd java && mvn generate-sources -Pcodegen
  • cd java && mvn spotless:apply && mvn test -Dtest=SessionEventDeserializationTest
  • PATH="$PWD/python/.venv/bin:$PATH" just validate-docs-check

Document envelope-level agentId in streaming events and clarify parent-agent rendering guidance. Mark parentToolCallId as deprecated for sub-agent attribution.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 20:02
@loganrosen loganrosen requested a review from a team as a code owner July 1, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the documentation to clarify how sub-agent attribution works in streamed session events, centering on the envelope-level agentId and guidance for rendering only the parent agent’s chat output while routing sub-agent activity elsewhere.

Changes:

  • Documented envelope-level agentId in the streaming event envelope and added renderer guidance to ignore sub-agent assistant events in the main chat UI.
  • Marked payload-level parentToolCallId as deprecated for sub-agent attribution across relevant event payload tables.
  • Noted in custom agents docs that sub-agent events share the parent session stream and can be separated via the envelope.
Show a summary per file
File Description
docs/features/streaming-events.md Adds agentId to the event envelope docs, introduces “render only the parent agent” guidance, and deprecates parentToolCallId for attribution.
docs/features/custom-agents.md Adds a clarification that sub-agent events share the parent stream and can be separated using envelope-level agentId.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread docs/features/streaming-events.md Outdated
loganrosen and others added 6 commits July 1, 2026 16:05
Add a hidden validation-only Python block for the parent-agent streaming example so docs validation has a typed session placeholder while keeping the visible snippet concise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a typed CopilotSession helper in the hidden validation snippet instead of typing the session as Any.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use the docs pipeline's supported TypeScript summary label for the new streaming-events tabbed example.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the quick-reference table note focused on payload fields rather than repeating sub-agent attribution guidance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use a single visible Python snippet for parent-response filtering instead of a hidden validation block plus duplicate visible example.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
print(event.data.delta_content, end="", flush=True)

session.on(handle)
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this showing code for only two of the six languages?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by adding equivalent examples for all six SDK languages. Java was the blocker because generated session events did not expose the envelope-level agentId; this now updates Java codegen/generated SessionEvent and adds deserialization coverage, so the docs can show the same filter everywhere.

loganrosen and others added 3 commits July 14, 2026 16:26
Remove the two-language parent-response snippet so the streaming events guide does not present uneven language coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add the generated Java session event envelope field for sub-agent attribution and restore equivalent parent-response streaming examples across all SDK languages.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f1fa1c7f-9fdc-4cd4-9279-586191a6a646
@loganrosen loganrosen requested a review from stephentoub July 14, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants