Skip to content

Refactor responses to leverage hosting for server and route registration#45921

Merged
lusu-msft merged 1 commit intoagentserver/invoke-reponsesfrom
gayang/invocation
Mar 25, 2026
Merged

Refactor responses to leverage hosting for server and route registration#45921
lusu-msft merged 1 commit intoagentserver/invoke-reponsesfrom
gayang/invocation

Conversation

@zhiyong-gayang
Copy link

Summary

  • Replace map_responses_server() with class-based ResponseHandler that plugs into AgentServer, matching the InvocationHandler pattern
  • Add @responses.create_handler decorator for registering response handlers (consistent with @invocations.invoke_handler)
  • Integrate hosting's TracingHelper for OTel spans, W3C trace context propagation, and baggage support
  • Fix Starlette 1.0.0 middleware compatibility in hosting _base.py (deprecated @app.middleware("http") → class-based Middleware)
  • Add MultiProtocol sample demonstrating both invocation and response protocols on a single AgentServer

Test plan

  • All 303 existing tests pass (6 skipped, pre-existing)
  • New integration tests verify health endpoint and multi-protocol composition
  • Manual verification: run samples/MultiProtocol/app.py and test both /invocations and /responses endpoints

🤖 Generated with Claude Code

… route registration

Replace the standalone map_responses_server() function with a class-based
ResponseHandler that plugs into AgentServer, following the same pattern as
InvocationHandler. This enables multi-protocol composition, unified tracing
via TracingHelper, automatic health probes, graceful shutdown delegation,
and the x-platform-server identity header via hosting middleware.

- Add ResponseHandler class with @create_handler decorator pattern
- Integrate hosting's TracingHelper for OTel spans, W3C propagation, baggage
- Fix Starlette 1.0.0 middleware compatibility in hosting _base.py
- Add MultiProtocol sample showing both protocols on one AgentServer
- Update all tests to use AgentServer + ResponseHandler pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the Hosted Agents sdk/agentserver/* label Mar 25, 2026
@lusu-msft lusu-msft merged commit 923e18d into agentserver/invoke-reponses Mar 25, 2026
4 of 5 checks passed
@lusu-msft lusu-msft deleted the gayang/invocation branch March 25, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants