Prerequisites
- Vibes installed (Installation guide)
- An Anthropic API key set in your environment:
export ANTHROPIC_API_KEY="sk-ant-..."
1
Create a bare agent
Start with the simplest possible agent: a model and a system prompt.
Agent takes a model and system prompt. agent.run() sends a message and returns a result. result.output is the text response.Without tools, the agent can only respond from its training data. Let’s fix that.
2
Add a tool
Give the agent real capabilities by defining a type-safe tool with Zod parameter validation.
tool() creates a type-safe tool with Zod parameter validation. The agent automatically calls tools when relevant. The _ctx parameter is the RunContext - we will use it later for dependency injection.3
Add structured output
Force the agent to return typed data by providing an
outputSchema.outputSchema forces the agent to return data matching your Zod schema. result.output is now typed as { city: string; temperature: number; condition: string; summary: string } instead of string. The agent will retry if validation fails.Structured output uses tool-based extraction by default. The agent calls a special output tool internally.
4
Test your agent
Test the agent without making real API calls using Run the test:
TestModel.TestModel simulates model responses without API calls. agent.override() creates a copy of the agent with the test model - the original agent is unchanged (immutable). setAllowModelRequests(false) blocks any accidental real API calls in your test suite.What’s next?
These concept deep-dives are coming soon.
Agents
Deep dive into the agent loop, system prompts, and run context.
Tools
Build type-safe tools with Zod schemas and dependency injection.
Dependencies
Inject services, databases, and other dependencies into your agents.