Spaces:
Sleeping
Sleeping
Claude SDK Integration
The Claude SDK integration provides composable ACE steps for the Anthropic Python SDK. Use it when you want direct Messages API access inside your own pipeline instead of a prebuilt runner.
Quick Start
from ace import Pipeline, Reflector, SkillManager, Skillbook, learning_tail
from ace.integrations import ClaudeSDKExecuteStep, ClaudeSDKToTrace
skillbook = Skillbook()
pipe = Pipeline([
ClaudeSDKExecuteStep(model="claude-sonnet-4-20250514"),
ClaudeSDKToTrace(),
*learning_tail(Reflector("gpt-4o-mini"), SkillManager("gpt-4o-mini"), skillbook),
])
Installation
uv add ace-framework[claude-sdk]
For observability, also install and configure Logfire:
uv add ace-framework[logfire]
from ace.observability import configure_logfire
configure_logfire()
What It Provides
ClaudeSDKExecuteStep— injects skillbook context, calls the Anthropic Messages API, and writes a validatedClaudeSDKResulttoctx.traceClaudeSDKToTrace— convertsClaudeSDKResultinto the standard ACE trace dict consumed byReflectStepClaudeSDKResult— Pydantic model with validated output, token usage, latency, tool calls, and raw response accessToolCall— Pydantic model for captured Claude tool invocations
Parameters
ClaudeSDKExecuteStep
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
str |
"claude-sonnet-4-20250514" |
Claude model ID |
system_prompt |
str | None |
None |
Base system prompt |
max_tokens |
int |
4096 |
Maximum output tokens |
temperature |
float |
0.0 |
Sampling temperature |
tools |
list[dict] | None |
None |
Anthropic tool definitions |
api_key |
str | None |
None |
Optional API key override |
base_url |
str | None |
None |
Optional API base URL |
inject_skillbook |
bool |
True |
Prepend skillbook context to the system prompt |
client |
Any |
None |
Injected Anthropic client for testing or custom transport |
Observability
When Logfire is configured, the step emits three layers of observability:
- Step-level
logfire.span(...)aroundClaudeSDKExecuteStep - Structured
logfire.info(...)andlogfire.error(...)events with tokens, latency, stop reason, and tool counts logfire.instrument_anthropic(client)auto-instrumentation for the underlying SDK calls
The result model also captures:
input_tokensoutput_tokenstotal_tokenslatency_secondsstop_reasontool_calls
Tool Use
tools = [
{
"name": "get_weather",
"description": "Get the current weather for a city.",
"input_schema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}
]
execute = ClaudeSDKExecuteStep(
model="claude-sonnet-4-20250514",
tools=tools,
)
If Claude returns tool use blocks, they are captured on
ClaudeSDKResult.tool_calls as validated ToolCall models.
Validation
ClaudeSDKExecuteStep validates its configuration with Pydantic before the
client is constructed. ClaudeSDKResult and ToolCall are also Pydantic
models, so invalid token counts, latency values, or malformed tool calls are
rejected early.
What to Read Next
- Integration Pattern — the shared INJECT/EXECUTE/LEARN design
- Composing Pipelines — mix SDK steps with other ACE steps