Anthropic's Tool Use Primitives for Building Agents Directly
Build a bounded tool-using agent on Anthropic's Messages API without a full multi-agent framework.
You own the loop: call the model, execute tool_use blocks, append tool_result messages, repeat until stop.
Define JSON-schema tools, send them on messages.create, detect stop_reason == "tool_use", run local handlers, and continue the conversation until the model returns an end turn (or you hit max steps).
OpenAI Agents SDK hides the loop behind Runner.
Anthropic's public agent posture for many teams is still: excellent tool primitives, explicit loop ownership.
Comparing them teaches when a high-level agent SDK is worth it versus a 40-line while-loop you fully control.
Yes, if the system repeatedly perceives, chooses tools, acts, and observes under stop conditions. Classes are packaging, not the definition.
How do I do multi-agent handoffs on Anthropic?
Implement them explicitly: either switch system prompts/tools mid-loop, or call specialist functions that run nested model calls. There is no single required handoff primitive.
Can I stream tool-using responses?
Yes with streaming Messages APIs. You still must assemble tool_use blocks and execute tools before continuing. Verify streaming event shapes at build.
Should I prefer a terminal `submit_answer` tool?
For automation pipelines, often yes. It makes completion machine-detectable and keeps free-text chats optional.
How does this compare to OpenAI function calling loops?
Conceptually identical: model proposes tools, host executes, results return. Block formats and SDK helpers differ; the control theory does not.
Where should MCP plug in?
As another tool source: list MCP tools, translate to Anthropic tool schemas, dispatch calls to the MCP client. The Messages loop stays yours.
What model id should I hardcode?
None permanently. Inject model ids from config and verify at build against current Anthropic docs.
How do I test the loop without spending tokens?
Unit test the dispatcher and stop logic with recorded fixtures. Integration-test one golden path against a real model in CI on a schedule if cost allows.
When should I abandon the thin loop for OpenAI Agents SDK or LangGraph?
When handoffs, guardrails, MCP lifecycle, or durable graph resume cost more to maintain than a dependency. See the decision cheatsheet in this section.
Do I need both Anthropic and OpenAI agent stacks?
Only if product strategy requires both model families with deep agent features. Many teams pick one primary native stack and keep tools portable.