fix: propagate sessionId as A2A contextId in Inspector proxy#892
Merged
avi-alpert merged 1 commit intoaws:mainfrom Apr 19, 2026
Merged
fix: propagate sessionId as A2A contextId in Inspector proxy#892avi-alpert merged 1 commit intoaws:mainfrom
avi-alpert merged 1 commit intoaws:mainfrom
Conversation
The Agent Inspector Chat UI already generates and tracks a sessionId per conversation and forwards it to the dev-server proxy on each invocation. However, handleA2AInvocation dropped this sessionId when building the A2A JSON-RPC body, so every turn arrived at the A2A agent with a fresh, auto-generated contextId. This broke multi-turn memory for any A2A agent that keys session state on the A2A contextId (e.g., Strands FileSessionManager(session_id=context.context_id)). Map sessionId to the A2A Message.contextId field when present. This is spec-compliant per A2A Protocol Spec §3.4.3 (clients MAY include contextId in subsequent messages to indicate continuation) and §3.4.1 (when contextId is omitted, the agent MAY generate a fresh one). Closes aws#891
avi-alpert
approved these changes
Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a bug where the Agent Inspector Chat UI (
agentcore dev) did not propagate the session identifier into the A2AMessage.contextIdfield. As a result, every turn against an A2A agent arrived with a freshly-generatedcontextId, and any agent-side session manager keyed on the A2AcontextId(e.g., StrandsFileSessionManager(session_id=context.context_id)) started a new empty session per turn, breaking multi-turn memory.The Inspector frontend already tracks a
sessionIdper conversation and forwards it to the dev-server proxy. The HTTP-protocol branch ofhandleInvocationscorrectly maps this to thex-amzn-bedrock-agentcore-runtime-session-idheader, but the A2A branch (handleA2AInvocation) silently dropped it when constructing the JSON-RPC body.This PR maps
sessionIdto the A2AMessage.contextIdfield when present.Change
const a2aBody = { jsonrpc: '2.0', id: a2aRequestId++, method: 'message/stream', params: { message: { messageId: randomUUID(), role: 'user', parts: [{ kind: 'text', text: prompt }], + ...(sessionId ? { contextId: sessionId } : {}), }, }, };A2A spec compliance
Both branches of the conditional are compliant with the A2A Protocol Specification:
sessionIdis present → the client sendscontextIdto indicate continuation. Per §3.4.3 Multi-Turn Conversation Patterns: "Clients MAY include thecontextIdin subsequent messages to indicate continuation of a previous interaction."sessionIdis absent → the message omitscontextId. Per §3.4.1 Context Identifier Semantics: "Agents MAY generate a newcontextIdwhen processing a Message that does not include acontextIdfield."Field naming (
contextId, camelCase) also matches §5.5 JSON Field Naming Convention.Scope
One-line change, A2A branch of
handleA2AInvocationonly. The HTTP and AGUI branches are not touched.Related Issue
Closes #891
Documentation PR
N/A — this is a runtime bugfix with no user-facing API or config change; the Inspector already exposes
sessionIdin the frontend, and A2A agents already acceptcontextIdper spec. No docs update is required.Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsTest results
npm run typecheck: clean (0 errors)npm run lint: 0 errors, 11 warnings — all pre-existing, in files unrelated to this change (HelpScreen.tsx,tui-harness/mcp/server.ts)npm run test:unit: ✅ Ran — no regressions introduced by this PR.main(v0.9.1, commitf2de452): 9 failed / 3306 passed (231 files)tui-harness/__tests__/proof-of-concept.test.ts,dev/__tests__/dev.test.tspositional prompt invoke,mcp/__tests__/AddGatewayJwtConfig.test.tsx). None exercisehandleA2AInvocation.src/cli/operations/dev/web-ui/__tests__/only containsmcp-proxy.test.ts).npm run test:integ: ❌ Not run — requires AWS credentials that are not configured in this environment.npm run build, linked vianpm link, and confirmed with a local StrandsA2AServerusingFileSessionManager(session_id=context.context_id):contextId.contextIdis forwarded across turns.context_id=<sessionId>is received on both turns.I did not add automated tests as part of this PR because (a) there is no existing test infrastructure for
handleA2AInvocationin the repo, and (b) per project conventions inCONTRIBUTING.md, I kept the change minimal. Happy to add tests in a follow-up if the maintainers would like.Checklist