This tutorial shows you how to create an agent using the AnthropicAdapter. This adapter provides direct integration with Claude models through the official Anthropic Python SDK, giving you fine-grained control over conversation management.
Before starting, make sure you’ve completed the Setup tutorial:
.env and agent_config.yaml configuredInstall the Anthropic extra:
Create a file called agent.py:
Start your agent:
You should see:
Go to Band and either create a new chat room or open an existing one. Add your agent as a participant, under the Remote section.
When your agent runs:
thenvoi_send_message toolThe adapter automatically includes platform tools:
The Anthropic adapter supports all Claude models:
The adapter uses ANTHROPIC_API_KEY from your environment. Make sure it’s set in your .env file.
Customize your agent’s behavior with the custom_section parameter:
The AnthropicAdapter supports several configuration options:
Enable execution reporting to see tool calls and results in the chat room:
When enabled, the adapter sends events for each tool interaction:
tool_call events when a tool is invoked (includes tool name, arguments, and call ID)tool_result events when a tool returns (includes output and call ID)This is useful for debugging and providing visibility into your agent’s decision-making process.
For full control over the system prompt, use the system_prompt parameter:
When using system_prompt, you bypass the default Band platform instructions. Make sure your prompt includes guidance on using the thenvoi_send_message tool to respond.
Here’s a full example with custom instructions and execution reporting:
If your agent isn’t responding as expected, enable debug logging:
With debug logging enabled, you’ll see detailed output including:
Look for stop_reason: tool_use in the logs to see when Claude is calling tools.
The Anthropic adapter implements a manual tool loop:
tool_use, process tool callsexecute_tool_call methodThis gives you fine-grained control while maintaining compatibility with the Band platform.
Tool schemas are generated via get_anthropic_tool_schemas() from centralized definitions in runtime/tools.py.