This example demonstrates basic tool-based grading using the built-in contains function with two different extractors.
- Using tool graders for deterministic, fast evaluation
- Testing agent web-fetching capabilities
- Setting pass/fail gates with threshold values
- Comparing different extractors:
last_assistantvstool_output
This example includes two separate suites that evaluate the same agent differently:
Uses the last_assistant extractor to check if the agent's final response contains the correct answer. This tests whether the agent can successfully fetch webpage content AND communicate the answer properly to the user.
Uses the tool_output extractor to check if the raw output from the read_webpage_content tool contains the correct answer. This tests whether the tool is successfully fetching and returning webpage content, independent of what the agent says.
Tool graders like contains are ideal when you have clear ground truth answers and need fast, deterministic evaluation. Different extractors let you evaluate different parts of the agent's behavior - you can test tool functionality separately from the agent's ability to process and communicate results.
Start your local Letta server:
letta serverThen run either or both evaluations:
cd examples/simple-tool-grader
# evaluate agent's final responses
letta-evals run last_assistant_suite.yaml
# evaluate tool outputs directly
letta-evals run tool_output_suite.yamlSet these environment variables:
export LETTA_API_KEY=your-api-key
export LETTA_PROJECT_ID=your-project-idUpdate base_url in suite.yaml:
target:
base_url: https://api.letta.com/Then run the evaluation as above.
This example uses two different datasets, each tailored to its evaluation strategy:
Used by last_assistant_suite.yaml. Contains specific answers the agent should extract and communicate:
input,ground_truth
"Read `https://www.york.ac.uk/teaching/cws/wws/webpage1.html`. What program is mentioned for writing HTML code? Respond with the program name ONLY in brackets, e.g. {Word}.",{Notepad}Key points:
ground_truth: Specific formatted answers (e.g.,{Notepad},{4},{.html})- Tests if the agent can extract specific information AND format it correctly
- Evaluates end-to-end behavior: tool usage + response generation
Used by tool_output_suite.yaml. Contains a sentence that should appear in the raw webpage content:
input,ground_truth
"Read `https://www.york.ac.uk/teaching/cws/wws/webpage1.html`. What program is mentioned for writing HTML code? Respond with the program name ONLY in brackets, e.g. {Word}.","HTML isn't computer code, but is a language that uses US English to enable texts (words, images, sounds) to be inserted and formatting such as colo(u)r and centre/ering to be written in."Key points:
ground_truth: A full sentence from the webpage that should appear in the tool's raw output- All samples use the same ground truth since they fetch the same webpage
- Tests if the tool successfully fetches webpage content, regardless of what the agent says
- Useful for isolating tool functionality from agent processing
name: fetch-webpage-last-assistant-test
description: Test if agent's final response contains the correct answer from fetched webpage
dataset: assistant_dataset.csv
target:
kind: letta_agent
agent_file: test-fetch-webpage-simple-agent.af
base_url: http://localhost:8283
graders:
contains_check:
kind: tool
function: contains
extractor: last_assistant
gate:
metric_key: contains_check
op: gte
value: 0.75Key points:
- Uses
assistant_dataset.csvwith specific formatted answers as ground truth extractor: last_assistantevaluates the final agent message- Tests end-to-end behavior: tool calling + response generation
gaterequires ≥75% pass rate (3+ out of 5 samples must pass)
name: fetch-webpage-tool-output-test
description: Test if the tool output from read_webpage_content contains the correct answer
dataset: tool_output_dataset.csv
target:
kind: letta_agent
agent_file: test-fetch-webpage-simple-agent.af
base_url: http://localhost:8283
graders:
tool_output_check:
kind: tool
function: contains
extractor: tool_output
extractor_config:
tool_name: read_webpage_content
gate:
metric_key: tool_output_check
op: gte
value: 0.75Key points:
- Uses
tool_output_dataset.csvwith a sentence from the webpage as ground truth extractor: tool_outputwithtool_name: read_webpage_contentevaluates raw tool outputextractor_configspecifies which tool's output to extract- Tests tool functionality independently of agent's response formatting
- Useful for debugging: isolates whether issues are with the tool or the agent's processing