Skip to content

feat: add BedrockTransport + wire all Bedrock transport paths#13814

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-d8d6444e
Apr 22, 2026
Merged

feat: add BedrockTransport + wire all Bedrock transport paths#13814
teknium1 merged 1 commit intomainfrom
hermes/hermes-d8d6444e

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Salvages #13467. Fourth and final transport — completes the transport layer with all four api_modes covered (issue #13473, Cycle 1).

Changes vs #13467

One adjustment from the original: the main normalize loop does NOT add a bedrock_converse branch to invoke normalize_response on the response. Bedrock's normalize_converse_response runs at the dispatch site (run_agent.py:5189), so the response already has the OpenAI-compatible .choices[0].message shape by the time the main loop sees it. Falling through to the chat_completions else branch is correct and sidesteps a redundant NormalizedResponse rebuild.

Everything else is preserved: build_kwargs, validate_response, finish_reason branch, normalize_response (still usable by direct callers), map_finish_reason.

Transport coverage — COMPLETE

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

Validation

Result
BedrockTransport tests 18 pass
All transport tests 117 pass
All bedrock/converse tests across tests/agent/ 160 pass
tests/run_agent/ 885/885 pass (+ 15 skipped; the single test_concurrent_interrupt failure is pre-existing on origin/main)
E2E — build_kwargs model, region, max_tokens, guardrail ✅
E2E — validate_response raw dict + normalized SimpleNamespace ✅
E2E — normalize_response text + tool call ✅
E2E — _build_api_kwargs integration

Closes #13467 (merging this credits @kshitijk4poor's original work).

Fourth and final transport — completes the transport layer with all four
api_modes covered.  Wraps agent/bedrock_adapter.py behind the ProviderTransport
ABC, handles both raw boto3 dicts and already-normalized SimpleNamespace.

Wires all transport methods to production paths in run_agent.py:
- build_kwargs: _build_api_kwargs bedrock branch
- validate_response: response validation, new bedrock_converse branch
- finish_reason: new bedrock_converse branch in finish_reason extraction

Based on PR #13467 by @kshitijk4poor, with one adjustment: the main normalize
loop does NOT add a bedrock_converse branch to invoke normalize_response on
the already-normalized response.  Bedrock's normalize_converse_response runs
at the dispatch site (run_agent.py:5189), so the response already has the
OpenAI-compatible .choices[0].message shape by the time the main loop sees
it.  Falling through to the chat_completions else branch is correct and
sidesteps a redundant NormalizedResponse rebuild.

Transport coverage — complete:
| api_mode           | Transport                | build_kwargs | normalize | validate |
|--------------------|--------------------------|:------------:|:---------:|:--------:|
| anthropic_messages | AnthropicTransport       | ✅            | ✅         | ✅        |
| codex_responses    | ResponsesApiTransport    | ✅            | ✅         | ✅        |
| chat_completions   | ChatCompletionsTransport | ✅            | ✅         | ✅        |
| bedrock_converse   | BedrockTransport         | ✅            | ✅         | ✅        |

17 new BedrockTransport tests pass.  117 transport tests total pass.
160 bedrock/converse tests across tests/agent/ pass.  Full tests/run_agent/
targeted suite passes (885/885 + 15 skipped; the 1 remaining failure is the
pre-existing test_concurrent_interrupt flake on origin/main).
@teknium1 teknium1 merged commit 57411fc into main Apr 22, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-d8d6444e branch April 22, 2026 03:58
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/bedrock AWS Bedrock (boto3, IAM) labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder 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