Start Debugging

anthropic-sdk

37 posts · Page 1 of 4

How to Change Claude's Effort Per Turn With a Mid-Conversation System Message

Stop rewriting output_config.effort between requests. Append {"role": "system", "content": [], "output_config": {"effort": "low"}} with the mid-conversation-output-config-2026-07-01 beta and claude-opus-5-5, claude-sonnet-5-5 or claude-haiku-5-5 switches effort from the next user turn while the prompt cache and preserved thinking stay valid. Placement, persistence, errors and an agent-loop helper.

How to Trace Anthropic SDK Calls With the Built-In OpenTelemetry Export

The Anthropic Python and TypeScript SDKs now emit OpenTelemetry spans on their own: register a tracer provider before the first call and every messages.create becomes an anthropic.messages.create CLIENT span with gen_ai.* token, model and stop-reason attributes. Content mode, conversation IDs, user.id baggage, linking to the Claude Platform's server-side spans, streaming and tool runner behavior, and the env-var override trap, checked against anthropic 2.8.0.

Retry and Backoff for Long Agent Loops Under Overloaded and Rate-Limit Errors

The Anthropic SDK retries a failed call twice in about 1.2 seconds, which is fine for a chat request and wrong for a 200-turn agent run. Classify every failure into retry-after, capacity, transient or terminal, retry the model turn (never the tool call), share one pause gate across workers, catch the mid-stream overloaded_error that arrives as a 200, and checkpoint so a dead run resumes. Tested against anthropic 2.3.0 for Python.

Migrate a Coding Agent from Claude Sonnet 4.6 and Opus 4.7 to the 5.5 Family: Model IDs, Effort, and Cost

Moving an agent from claude-sonnet-4-6 or claude-opus-4-7 to claude-sonnet-5-5 or claude-opus-5-5 is not just a model ID swap. Thinking is always on, thinking-off and forced tool_choice now return 400, the effort defaults moved, Sonnet counts about 30% more tokens, and Claude Code ignores your old effortLevel on Opus 5.5. Here is the full checklist with before/after code.

What Is Tool Calling and Why JSON Schemas Matter More Than Prompts

Tool calling is a protocol, not magic: the model emits a structured request matching a JSON Schema you supplied, your code runs it, and the result goes back as a message. The schema and its descriptions are rendered into the model's prompt and, with strict mode, into a decoding grammar, so they shape behaviour more reliably than any system-prompt instruction. Here is how it works on claude-sonnet-5-5 and OpenAI strict mode, with schema patterns that make invalid calls impossible.

What Is the Difference Between an AI Agent and an AI Workflow?

In a workflow, your code decides the next step and the model fills in each step. In an agent, the model decides the next step and your code only executes it. That one question (who owns the control flow) determines cost, latency, testability and failure modes. Here is the distinction as Anthropic, Microsoft Agent Framework and LangGraph define it, with the same task built both ways in Python against claude-haiku-4-5 and claude-sonnet-5-5.
Next