Propagate request handler agent metadata#1949
Conversation
There was a problem hiding this comment.
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, andinteractionTypeinto 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
This comment has been minimized.
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>
39cb52f to
10ceaff
Compare
Cross-SDK Consistency Review ✅This PR implements Field naming (language-idiomatic) ✅
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 Copy constructors/mutation helpers ✅.NET's copy constructor, Java's E2E test coverage ✅All six SDKs have matching E2E tests verifying:
.NET-specific GET/HEAD fixThe Summary: Excellent coordination — all SDKs are updated in lock-step with consistent semantics and matching test coverage.
|
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
agentId,parentAgentId, andinteractionTypefromllmInference.httpRequestStartinto request-handler contexts for Node, Python, Go, .NET, Rust, and Java.parentAgentId.Validation
clangrequired byringbefore SDK tests compile.Generated by Copilot