Skip to main content
Large language models generate content. Agents pursue goals: they take multiple turns, call tools, and act on the results. Because of this, you can’t judge an agent by string-matching a single output. Instead, you evaluate its behavior across a trajectory. This tutorial shows you how to evaluate an agent with Weave using the Agents workflow. Weave traces your agent as a conversation of turns and tool calls, and you score it with weave.EvaluationLogger. You build a small customer-support agent, score task completion for single-turn and multi-turn interactions, and compare two versions of the agent.

What you’ll learn

This guide shows you how to:
  • Build and trace an agent as a conversation of turns and tool calls.
  • Score single-turn task completion with an LLM judge.
  • Organize and compare agent evaluations in the Weave UI.
  • Score a multi-turn conversation.
  • Extend your scorers beyond task completion.
A few terms are used throughout: a task is one row of your dataset, a trial is one run of the agent on a task, the transcript is the traced conversation, and a scorer (or grader) assigns a score to a trial. Weave is the harness that organizes these. Weave doesn’t run or sandbox your agent, so you keep whatever agent runtime you already have.
In this tutorial, the agent runs on Claude Sonnet and the judge runs on Claude Opus. Grading with a different model than the one you’re evaluating is good evaluation practice.

Prerequisites

This tutorial requires the following:
  • A W&B account.
  • Python 3.10+.
  • Required packages installed: pip install weave anthropic.
  • An Anthropic API key set as the ANTHROPIC_API_KEY environment variable.

Build and trace the agent

The agent answers refund requests using two tools, lookup_order and issue_refund, under a policy that allows refunds only within 30 days. The full agent, including the tool definitions, the model loop, and message conversion, is in the accompanying notebook. This section focuses on the Weave-specific part. First, initialize Weave:
This tutorial instruments the agent by hand, so it turns implicit patching off. Otherwise Weave’s built-in Anthropic integration would also log each model call as a legacy Op, duplicating the spans you record manually. If you build your agent with an agent-framework integration instead, keep implicit patching on, as described in the tip at the end of this section. Trace the agent with the Conversation SDK. A conversation contains turns, and each turn contains the model call and any tool calls:
The snippets in this tutorial focus on the Weave calls and use placeholders for your own agent code:
  • convo_id and new_id(): a unique ID for each conversation, such as a UUID.
  • user_message: the user’s input for the turn.
  • anthropic_client: an initialized Anthropic client.
  • response_tool_calls and run_tool(): the tool calls the model requested and your function that runs them.
  • run_agent_turn(): the full agent loop that ties the preceding pieces together.
  • task_completion() and judge_task: the LLM judge and the task it scores, introduced in the following section.
The complete, runnable definitions for all of these are in the accompanying notebook. Run one request and open the printed Weave link. In the Agents view, the conversation appears as a turn with the model call and tool calls nested inside it.
This tutorial instruments the agent by hand. Alternatively, if you build your agent with an agent-framework integration such as the Claude Agent SDK or OpenAI Agents, Weave emits these same Agents spans automatically: keep implicit patching on (the default) and skip the manual start_* calls. Auto-patching the bare provider SDK, by contrast, produces legacy Ops and Calls, not Agents spans, which is why the hand-instrumented path turns it off.

Score task completion

Task completion asks a single question: did the agent achieve the goal? A judge model reads the transcript and decides against the task’s success criteria. It rewards the correct outcome, not a polite-sounding reply. Define a small task suite:
Write the scorer as an LLM judge that returns a pass or fail with a reason. The judge prompts Claude for a JSON verdict and parses it, which works across SDK versions. The full judge is in the accompanying notebook:
Now drive the evaluation with EvaluationLogger. The key step is to run the agent inside log_prediction(...), so that the traced agent conversation links to the evaluation result:
Open the evaluation link. Each row is a task with its task-completion score, output, latency, and cost, and a link to the full agent transcript for that trial. When a task fails, that link takes you straight to the conversation that produced it.
Task completion is one signal, not the whole score. Add more signals with extra pred.log_score(...) calls in the same block, for example tool_call_correct or instruction_following.

Organize and compare evaluations

To compare two versions of your agent, run the same evaluation again with a different model label:
Weave lays the runs side by side in the comparison view, so you can read the task-completion rate, tool-call correctness, latency, and cost for v1 against v2. This answers the baseline-relative question of whether a change did as well as the baseline. Every row still links to its transcript, so a regression is one click from the failing conversation.

Score a multi-turn conversation

To evaluate a turn in context, load a fixed conversation history, append one new user turn, and score how the agent handles it. In other words, given the conversation state so far, does the agent handle the next turn well? Each dataset row carries the prior turns plus the next message. In the following example, the order ID appears only in the history, so a good agent uses that context instead of asking again:
As with the single-turn evaluation, each row links back to its full transcript, so you can inspect whether the agent used the prior context or re-asked for the order ID.
This approach scores the next turn against a fixed history, which is the practical offline method. Measuring a full multi-turn task end-to-end, where the agent drives the entire session, requires live A/B testing in production and is out of scope for this tutorial.

Extend your scorers

Evaluating real agents requires a set of scores that covers two dimensions:
  • Functional: tool-call correctness, instruction-following, and recovery from tool errors.
  • Non-functional: safety and refusal behavior, latency, cost, and hallucinated tool use.
Add each as another pred.log_score(name, value) call inside the prediction block.

Next steps

You traced an agent as a conversation, scored task completion for single-turn and multi-turn interactions, and compared versions, all linked back to the agent transcripts.