Refactor responses to leverage hosting for server and route registration#45921
Merged
lusu-msft merged 1 commit intoagentserver/invoke-reponsesfrom Mar 25, 2026
Merged
Refactor responses to leverage hosting for server and route registration#45921lusu-msft merged 1 commit intoagentserver/invoke-reponsesfrom
lusu-msft merged 1 commit intoagentserver/invoke-reponsesfrom
Conversation
… 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>
lusu-msft
approved these changes
Mar 25, 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.
Summary
map_responses_server()with class-basedResponseHandlerthat plugs intoAgentServer, matching theInvocationHandlerpattern@responses.create_handlerdecorator for registering response handlers (consistent with@invocations.invoke_handler)TracingHelperfor OTel spans, W3C trace context propagation, and baggage support_base.py(deprecated@app.middleware("http")→ class-basedMiddleware)MultiProtocolsample demonstrating both invocation and response protocols on a singleAgentServerTest plan
samples/MultiProtocol/app.pyand test both/invocationsand/responsesendpoints🤖 Generated with Claude Code