Anthropic Claude Agent SDK¶
agent_airlock.integrations.anthropic_claude_agent_sdk is the canonical
adapter for the Anthropic Claude Agent SDK. It is a thin
facade over the existing claude_*.py family (managed-agents, auto-memory,
task-budget) so callers can find the entrypoint without learning the
internal module layout.
Install¶
The extra pins claude-agent-sdk>=0.1.58. The SDK is not imported at
module load — calling wrap_agent without the extra installed raises a
clear ClaudeAgentSDKMissingError with the install hint
(never an opaque ImportError from somewhere deep in the call stack).
Quickstart¶
from agent_airlock.integrations.anthropic_claude_agent_sdk import (
AnthropicClaudeAgentSDKAdapter,
)
from agent_airlock.policy import STRICT_POLICY
# Real SDK shape — claude_agent_sdk.Agent or anything exposing `tools`.
agent = build_my_claude_agent()
adapter = AnthropicClaudeAgentSDKAdapter()
secured = adapter.wrap_agent(agent, policy=STRICT_POLICY)
# Every tool callable is now Airlock-decorated:
# - ghost arguments stripped
# - Pydantic V2 strict validation
# - PolicyViolation raised on denied tools
secured.run("Summarise the latest commit on main.")
What the adapter does¶
- Walks
agent.tools(dict or list) and replaces each tool'sforward/__call__with anAirlock(policy=...)-wrapped shim. - Re-exports the harness defences from the existing
claude_*.pymodules so callers can compose: ManagedAgentsAuditConfig— beta-header + toolset-version + tool intersection check on the managed-agents request boundary.AutoMemoryAccessPolicy+guarded_read/guarded_write— per-tenant scope, byte quota, redaction-on-write.build_task_budget_headers+build_output_config— populated by the adapter'stask_budget_request_kit(remaining=...)helper.- Pins a
SUPPORTED_SDK_VERSIONS = ("0.1.58",)tuple so callers can detect SDK drift early. New versions are added once smoke-tested.
Honest scope¶
- The adapter does not import the SDK at module load — passing a stub
agent (any object with a
toolsattribute) works without the extra installed. This is what the test suite uses, and it's also useful in CI environments without the optional dep. - Real SDK objects (whose
__module__starts withclaude_agent_sdk.*) do trigger the import check. If the extra is missing, the adapter raisesClaudeAgentSDKMissingErrorwith a clear install hint. - The Claude Agent SDK has churned twice between Sep-2025 and
Apr-2026. If a release renames
Agentor shifts the tools dict shape, the adapter logs but does not hard-fail — updateSUPPORTED_SDK_VERSIONSonce you've smoke-tested the new pin.