Skip to content

fix: forward caller's bearer token from chat_stream to capability providers - #88

Merged
kevwilliams merged 1 commit into
mainfrom
fix/chat-stream-identity-forwarding
Sep 12, 2026
Merged

kevwilliams merged 1 commit into
mainfrom
fix/chat-stream-identity-forwarding

Conversation

@kevwilliams

Copy link
Copy Markdown
Contributor

Summary

Live in staging: a chat turn through POST /chat/conversations/{contextId}/sendmessage (#85) completed, but the compute tool call inside it reported "no identity was forwarded."

POST /a2a's authMiddleware stamps the caller's raw bearer token onto the request context after authenticating it (auth.ContextWithBearerToken), which is what lets internal/agent thread it into capability.CallerIdentity for a provider like compute's MCP tool. chat_stream.go authenticates independently, since it doesn't run through that middleware, and never did the same stamp, so auth.BearerTokenFromContext read empty downstream. Same failure this endpoint exists to fix, one hop later.

Adds the missing ctx = auth.ContextWithBearerToken(...) call, and a regression test (TestChatStream_ForwardsBearerTokenForCapabilityProviders) asserting the token actually reaches the context Run receives — confirmed it fails without the fix and passes with it.

Test plan

  • go build ./... && go vet ./... && go test ./...
  • Confirmed the new test fails on the pre-fix code and passes after
  • After merge and staging reconcile: retry the same chat turn that surfaced this live, confirm the compute tool call succeeds

…viders

POST /a2a's authMiddleware stamps the caller's raw bearer token onto
the request context (auth.ContextWithBearerToken) after authenticating
it, which is what lets internal/agent thread it into
capability.CallerIdentity for a provider like compute's MCP tool.

chat_stream.go authenticates independently rather than going through
that middleware, and never did the same stamp. Confirmed live in
staging: a chat turn through POST /chat/.../sendmessage completed, but
the compute tool call inside it reported no identity was forwarded,
because the token never reached the context Run received.
@kevwilliams
kevwilliams merged commit 44f9e7b into main Sep 12, 2026
5 checks passed
@kevwilliams
kevwilliams deleted the fix/chat-stream-identity-forwarding branch September 12, 2026 19:52
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