feat: add transport types + migrate Anthropic normalize path#13073
Closed
kshitijk4poor wants to merge 1 commit into
Closed
feat: add transport types + migrate Anthropic normalize path#13073kshitijk4poor wants to merge 1 commit into
kshitijk4poor wants to merge 1 commit into
Conversation
Add agent/transports/types.py with three shared dataclasses: - NormalizedResponse: content, tool_calls, finish_reason, reasoning, usage, provider_data - ToolCall: id, name, arguments, provider_data (per-tool-call protocol metadata) - Usage: prompt_tokens, completion_tokens, total_tokens, cached_tokens Add normalize_anthropic_response_v2() to anthropic_adapter.py — wraps the existing v1 function and maps its output to NormalizedResponse. One call site in run_agent.py (the main normalize branch) uses v2 with a back-compat shim to SimpleNamespace for downstream code. No ABC, no registry, no streaming, no client lifecycle. Those land in PR 3 with the first concrete transport (AnthropicTransport). 46 new tests: - test_types.py: dataclass construction, build_tool_call, map_finish_reason - test_anthropic_normalize_v2.py: v1-vs-v2 regression tests (text, tools, thinking, mixed, stop reasons, mcp prefix stripping, edge cases) Part of the provider transport refactor (PR 2 of 9).
Contributor
This was referenced Apr 21, 2026
This was referenced May 16, 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
PR 2 of the provider transport refactor (PR 1: #12975).
Adds shared transport types and migrates one real production path through them.
What ships
agent/transports/types.py— Three dataclasses:NormalizedResponse:content,tool_calls,finish_reason,reasoning(shared),usage,provider_data(opaque)ToolCall:id(str|None),name,arguments,provider_data(per-tool-call protocol metadata)Usage:prompt_tokens,completion_tokens,total_tokens,cached_tokensbuild_tool_call(),map_finish_reason()normalize_anthropic_response_v2()inanthropic_adapter.py— wraps the existing v1 function and maps output toNormalizedResponse. One call site inrun_agent.py(main normalize branch, L11375) uses v2 with a back-compat shim.Design decisions
content,tool_calls,finish_reasonreasoning_build_assistant_messageL6975-7011). NOT a protocol quirk.reasoning_detailsprovider_datacodex_reasoning_itemsprovider_datacall_id,response_item_idToolCall.provider_dataextra_contentToolCall.provider_dataNo ABC, no registry, no
base.py, no streaming, no client lifecycle. Those land in PR 3 withAnthropicTransport.Test plan
test_types.py: dataclass construction, build_tool_call, map_finish_reasontest_anthropic_normalize_v2.py: v1-vs-v2 regression (text, tools, thinking, mixed, stop reasons, mcp prefix, edge cases)