Skip to content

feat: replace Anthropic monkey-patch with native Bedrock Converse API provider#1

Open
JiaDe-Wu wants to merge 1 commit into
aws-samples:mainfrom
JiaDe-Wu:feat/native-bedrock-converse-api
Open

feat: replace Anthropic monkey-patch with native Bedrock Converse API provider#1
JiaDe-Wu wants to merge 1 commit into
aws-samples:mainfrom
JiaDe-Wu:feat/native-bedrock-converse-api

Conversation

@JiaDe-Wu

Copy link
Copy Markdown

Summary

Replace the anthropic.Anthropic -> AnthropicBedrock monkey-patch with Hermes Agent's native Bedrock provider (provider="bedrock"), which uses the Converse API directly via boto3.

Why

The current monkey-patch routes all API calls through the Anthropic SDK's Bedrock adapter, which limits model support to Claude only. The native Bedrock provider uses the Converse API, which supports all Bedrock models — Claude, Nova, DeepSeek, Llama, Mistral, etc.

What Changed

File Change
app/hermes/main.py Deleted monkey-patch (~50 lines), use provider="bedrock"
bridge/contract.py Default provider anthropic -> bedrock
bridge/bedrock_provider.py Simplified — Converse API handles model routing
bridge/Dockerfile Added [bedrock] extra for boto3
cdk.json Default model uses inference profile ID

Net: -76 lines (mostly monkey-patch deletion).

Dependency

Requires NousResearch/hermes-agent#7920 (native Bedrock Converse API provider) to be merged upstream, or the hermes-agent submodule pointed to the fork branch: JiaDe-Wu/hermes-agent@feat/native-aws-bedrock-provider.

Benefits

  • All Bedrock models, not just Claude
  • No monkey-patching — clean configuration
  • Native streaming with delta callbacks
  • Bedrock Guardrails support
  • Dynamic model discovery
  • Error classification (ThrottlingException, context overflow, etc.)

… provider

Replace the anthropic.Anthropic -> AnthropicBedrock monkey-patch with
Hermes Agent native Bedrock provider (provider="bedrock"), which uses
the Converse API directly via boto3.

Benefits:
- Supports ALL Bedrock models (Claude, Nova, DeepSeek, Llama, Mistral)
  not just Claude (Anthropic SDK limitation)
- No monkey-patching — clean provider="bedrock" configuration
- Native streaming, tool calling, error classification, Guardrails
- Dynamic model discovery via ListFoundationModels

Changes:
- app/hermes/main.py: Delete monkey-patch, use provider="bedrock"
- bridge/contract.py: Default provider anthropic -> bedrock
- bridge/bedrock_provider.py: Simplified (Converse API handles routing)
- bridge/Dockerfile: Add [bedrock] extra for boto3
- cdk.json: Use inference profile ID as default model

Depends on: NousResearch/hermes-agent#7920 (native Bedrock provider PR)
Ref: https://github.com/JiaDe-Wu/sample-hermes-agent-on-aws-with-bedrock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant