Skip to main content
The SDK patches boto3’s Bedrock clients so calls to Amazon Bedrock are policy-checked and audited the same way OpenAI / Anthropic / Google calls are. Two boto3 services are covered:
  • bedrock-runtimeConverse, ConverseStream, plus the legacy InvokeModel shapes. The agentic loop runs in Python, so the SDK can intercept every turn.
  • bedrock-agent-runtimeInvokeAgent for managed Bedrock Agents whose Action Groups execute on AWS-managed infrastructure.
After egisai.init() runs, both clients are patched in place on every new boto3.client(…) instance.

Supported surface

Install

The Bedrock patch is part of the core SDK; no extra extra is required.

Use — Bedrock Converse

Streaming

Tool use

When the model returns toolUse blocks, the SDK runs output-side policies (deny_tool_call, deny_mcp_call, semantic_guard, deny_bash_command, deny_db_query, deny_financial_action) against them before they return to your dispatch code. A blocked tool call either raises PermissionError or returns a refusal-shaped response, depending on on_block. Tool results you feed back in the next call’s messages are scanned by the input phase, so PII in a CRM or database lookup gets caught before the model is shown it.

Use — managed Bedrock Agents

Bedrock Agents enforcement is advisory. Bedrock Agents run their Action Groups on AWS-managed infrastructure that does not expose a pre-execution or post-execution hook the SDK can sit between. The patch records what happened — tool dispatches, action results, the matched policy — but cannot prevent the dispatch or substitute the result before the agent is shown it. Audit rows are honestly stamped enforcement_status="advisory" so SOC 2 / GDPR auditors can query for them.If your application requires hard pre-execution gating OR tool-result PII masking for Bedrock workloads, use one of:
  • Bedrock Converse — drive the agentic loop yourself in Python. Tool results round-trip Python and the next call’s input phase scans them. This is the recommended path for regulated workloads.
  • Claude Agent SDK — the SDK’s subprocess-loop framework with real PreToolUse + PostToolUse hooks. See Claude Agent SDK.

When a call is blocked

By default a blocked call raises PermissionError. Switch modes at init if you’d rather receive a refusal-shaped Converse response:
The stub mirrors the real Converse / ConverseStream / InvokeAgent response shape so your existing code keeps working.

What’s next

Claude Agent SDK

Tier 3 framework with PreToolUse + PostToolUse enforcement.

Agent frameworks

Other agent frameworks supported by the SDK.