Skip to content

Propagate request handler agent metadata#1949

Open
stephentoub wants to merge 1 commit into
mainfrom
stephentoub-propagate-callback-fields
Open

Propagate request handler agent metadata#1949
stephentoub wants to merge 1 commit into
mainfrom
stephentoub-propagate-callback-fields

Conversation

@stephentoub

Copy link
Copy Markdown
Collaborator

The runtime now sends agent metadata on LLM inference request-start frames, but the SDKs also have hand-written request-handler adapters that were only exposing older fields like the session id. This threads the new metadata through those public callback contexts so consumers can identify the active agent, parent agent, and interaction type across SDKs.

Summary

  • Propagate agentId, parentAgentId, and interactionType from llmInference.httpRequestStart into request-handler contexts for Node, Python, Go, .NET, Rust, and Java.
  • Extend CAPI/BYOK request-handler E2Es to assert root-agent metadata is visible.
  • Extend subagent E2Es, and add Java subagent coverage, to assert subagent inference requests carry a distinct parentAgentId.
  • Fix .NET request-handler forwarding so GET/HEAD requests do not get an empty content body while forwarding headers.

Validation

  • Node targeted E2Es for request-handler session metadata and subagent hooks passed.
  • Python targeted E2Es for request-handler session metadata and subagent hooks passed.
  • Go targeted E2Es for request-handler session metadata and subagent hooks passed.
  • .NET targeted E2Es for request-handler session metadata and subagent hooks passed on net8.0 and net472.
  • Java targeted Maven verify for request-handler session metadata and subagent hooks passed.
  • Formatting and whitespace checks passed; Rust test compilation remains locally blocked by missing clang required by ring before SDK tests compile.

Generated by Copilot

Copilot AI review requested due to automatic review settings July 8, 2026 16:50
@stephentoub stephentoub requested a review from a team as a code owner July 8, 2026 16:50

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

This PR propagates agent metadata (agentId, parentAgentId, interactionType) from runtime llmInference.httpRequestStart frames into the public request-handler callback context across all SDKs, and extends E2E coverage (including new Java subagent coverage) to assert that metadata is visible—especially for subagent inference where parentAgentId should differ from agentId.

Changes:

  • Thread agentId, parentAgentId, and interactionType into request-handler contexts in Node, Python, Go, .NET, Rust, and Java adapters.
  • Extend request-handler E2Es (CAPI/BYOK) to assert root-agent metadata is populated on inference requests.
  • Extend subagent E2Es (and add Java subagent coverage) to assert subagent inference requests include a distinct parentAgentId.
Show a summary per file
File Description
rust/tests/e2e/subagent_hooks.rs Adds request-handler recording and asserts subagent inference carries parent/child agent metadata.
rust/tests/e2e/copilot_request_handler.rs Extends intercepted request records and assertions to include agent metadata on inference requests.
rust/src/copilot_request_handler.rs Adds agent metadata fields to CopilotRequestContext and wires them from httpRequestStart.
python/e2e/test_subagent_hooks_e2e.py Records request context metadata and asserts subagent inference includes parent_agent_id.
python/e2e/test_copilot_request_session_id_e2e.py Extends request interception records to include agent metadata and asserts presence.
python/copilot/copilot_request_handler.py Threads agent metadata from exchange into CopilotRequestContext.
nodejs/test/e2e/subagent_hooks.e2e.test.ts Adds request-handler recording and asserts subagent inference metadata is present/distinct.
nodejs/test/e2e/copilot_request_session_id.e2e.test.ts Extends intercepted request records to include agent metadata and asserts presence.
nodejs/src/copilotRequestHandler.ts Extends CopilotRequestContext and exchange context wiring for agent metadata.
java/src/test/java/com/github/copilot/SubagentHooksE2ETest.java New Java E2E validating subagent hooks and request-handler agent metadata.
java/src/test/java/com/github/copilot/CopilotRequestTestSupport.java Extends intercepted-request test record to include agent metadata.
java/src/test/java/com/github/copilot/CopilotRequestSessionIdE2ETest.java Adds assertions that inference requests include agent metadata.
java/src/main/java/com/github/copilot/LlmInferenceAdapter.java Parses agent metadata fields from request-start params and populates request context.
java/src/main/java/com/github/copilot/CopilotRequestContext.java Adds agent metadata fields + getters; ensures withUrl/withHeaders preserve them.
go/internal/e2e/subagent_hooks_e2e_test.go Adds RoundTripper-based recording and assertions for subagent inference agent metadata.
go/internal/e2e/copilot_request_session_id_e2e_test.go Extends intercepted request records and asserts agent metadata on inference requests.
go/copilot_request_handler.go Extends CopilotRequestContext with agent metadata and wires from HttpRequestStart.
dotnet/test/E2E/SubagentHooksE2ETests.cs Records request contexts and asserts subagent inference includes distinct parent/child agent ids.
dotnet/test/E2E/CopilotRequestSessionIdE2ETests.cs Adds assertions that intercepted inference requests include agent metadata.
dotnet/test/E2E/CopilotRequestE2EProvider.cs Extends intercepted request record shape to include agent metadata.
dotnet/src/CopilotRequestHandler.cs Adds agent metadata to CopilotRequestContext and fixes header forwarding logic for GET/HEAD.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

This comment has been minimized.

Thread agentId, parentAgentId, and interactionType from llmInference request-start frames into the public request handler contexts across SDK languages.

Extend CAPI/BYOK and subagent request-handler tests to prove the metadata is observable, and fix .NET forwarding so GET/HEAD requests do not get an empty content body when forwarding headers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@stephentoub stephentoub force-pushed the stephentoub-propagate-callback-fields branch from 39cb52f to 10ceaff Compare July 8, 2026 22:24
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR implements agentId, parentAgentId, and interactionType propagation consistently across all six SDK implementations. No cross-SDK inconsistencies were found.

Field naming (language-idiomatic) ✅

SDK Fields
Node.js agentId, parentAgentId, interactionType (optional string)
Python agent_id, parent_agent_id, interaction_type (str | None)
Go AgentID, ParentAgentID, InteractionType (string, empty = absent)
.NET AgentId, ParentAgentId, InteractionType (string?)
Java agentId(), parentAgentId(), interactionType() (@Nullable String)
Rust agent_id, parent_agent_id, interaction_type (Option<String>)

All names follow each language's established conventions and are parallel in semantics.

Nullability/absent-value semantics ✅

Go uses empty string for absent values (consistent with the existing SessionID field pattern in that SDK). All other SDKs use nullable/optional types. Both approaches are idiomatic for their respective languages.

Copy constructors/mutation helpers ✅

.NET's copy constructor, Java's withUrl() / withHeaders(), and other value-copy paths all correctly thread the new fields through.

E2E test coverage ✅

All six SDKs have matching E2E tests verifying:

  • Root-agent requests carry non-empty agentId and interactionType
  • Subagent requests additionally carry a non-empty parentAgentId distinct from agentId

.NET-specific GET/HEAD fix

The hasBody guard on content-header forwarding is a .NET-specific fix (.NET's HttpRequestMessage separates request headers from content headers at the API level). This is not a cross-SDK concern.

Summary: Excellent coordination — all SDKs are updated in lock-step with consistent semantics and matching test coverage.

Generated by SDK Consistency Review Agent for issue #1949 · sonnet46 1.7M ·

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.

2 participants