Skip to content

feat: add BedrockTransport + wire all Bedrock transport paths - #27075

Closed
Master-Rensei wants to merge 1 commit into
NousResearch:mainfrom
Master-Rensei:feat/bedrock-transport
Closed

feat: add BedrockTransport + wire all Bedrock transport paths#27075
Master-Rensei wants to merge 1 commit into
NousResearch:mainfrom
Master-Rensei:feat/bedrock-transport

Conversation

@Master-Rensei

Copy link
Copy Markdown

Summary

PR 6 of the provider transport refactor (PRs 1-5: #12975, #13073, #13366, #13430, #13447).

Fourth and final transport — completes the transport layer with all 4 api_modes covered. All transport methods wired to production paths.

What ships

agent/transports/bedrock.py — BedrockTransport (155 lines)

All transport methods wired:

Method Site in run_agent.py
build_kwargs() _build_api_kwargs bedrock branch (L6713)
normalize_response() Main normalize loop — new bedrock_converse branch (L10828)
validate_response() Response validation — new bedrock_converse branch (L9389)
finish_reason Finish reason extraction — new bedrock_converse branch (L9559)
convert_messages() / convert_tools() Called internally via build_kwargs()

normalize_response() handles two shapes: raw boto3 dicts (from direct converse calls) and already-normalized SimpleNamespace with .choices (from the dispatch site at L5169).

The truncation path (L9588) intentionally groups bedrock with chat_completions — both have the same response.choices shape because normalize_converse_response already runs at the dispatch site.

Transport coverage — complete

api_mode Transport build_kwargs normalize validate finish_reason
anthropic_messages AnthropicTransport
codex_responses ResponsesApiTransport
chat_completions ChatCompletionsTransport
bedrock_converse BedrockTransport

Test plan

  • 17 new tests (build_kwargs: 3, convert_tools: 1, validate: 4, map_finish_reason: 5, normalize: 2, registration: 2)
  • 231 bedrock/converse/transport tests pass (0 failures)

Add BedrockTransport wrapping agent/bedrock_adapter.py behind the
ProviderTransport ABC. Fourth and final transport.

Wire ALL transport methods to production paths in run_agent.py:
- build_kwargs: _build_api_kwargs bedrock branch (L6713)
- normalize_response: main normalize loop, new bedrock_converse branch
  (handles both raw boto3 dicts and already-normalized SimpleNamespace)
- validate_response: response validation, new bedrock_converse branch
- finish_reason: new bedrock_converse branch in finish_reason extraction

The truncation path (L9588) intentionally groups bedrock with
chat_completions — both have the same response.choices shape because
normalize_converse_response runs at the dispatch site.

17 new tests. 231 bedrock/converse/transport tests pass (0 failures).

PR 6 of the provider transport refactor.
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/bedrock AWS Bedrock (boto3, IAM) labels May 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #13814 (already merged). This PR reopens a previously closed fork branch, but the feature (BedrockTransport) was already landed via a salvage PR.

@Master-Rensei Master-Rensei closed this by deleting the head repository May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants