Skip to main content
In this tutorial you will build a weather agent from scratch. You will start with a bare agent, add a tool, add structured output, and write a test - all in one progressive flow. By the end, you will have a fully tested, type-safe agent.

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.
The tool’s description helps the model decide when to call it. Be specific!
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 TestModel.
Run the test:
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.