- Test agent behavior: Run agents against predefined test cases
- Measure performance: Use custom evaluators to score responses
- Track experiments: All results are logged to Langfuse for analysis
- Automate CI/CD: Integrate evaluations into your deployment pipeline
Built on Langfuse experiments. Your evaluation results are automatically visualized in your Langfuse dashboard for comparison and analysis.
Prerequisites
Before using the evaluation framework, ensure you have:-
Langfuse credentials configured:
.env
- BB AI SDK installed in your project
Quick start
Get evaluations running in 5 steps:-
Initialize the evals folder. Run the CLI command to scaffold the evals structure:
This creates an
evals/folder with:Configure observability inevals/__init__.py(match your FastAPI app’sservice_name/environment; pinbb-ai-sdk==0.1.9). The CLI scaffold may name this helperinit_observability():Install the matching[instrument-agno](or langchain/langgraph) extra. LangChain/LangGraph can also use callback handlers. See Observability. -
Register your agent task. Edit
evals/agents.pyto register your agent as a task function:agents.pyThe task name in@register_task("my_agent")must match thenamefield in your config file. -
Create a custom evaluator. Edit
evals/evaluators.pyto define how responses are scored:evaluators.pyThe custom evaluator name in@register_evaluator("accuracy_evaluator")must match the name used in your config file. -
Configure the experiment. Edit
evals/evals_config.yamlto define your evaluation:evals_config.yaml -
Create a dataset. Add a CSV file at
evals/datasets/my_dataset.csv:my_dataset.csvRun evaluations withbb-ai-sdk evals runand view results in your Langfuse dashboard!
Registering task functions
Task functions connect your agents to the evaluation framework. They define how to invoke your agent and return results.Task function signature
All task functions must:-
Accept keyword arguments including
item(with.inputattribute) -
Return a string result
Creating custom evaluators
Evaluators score agent responses against expected outputs or custom criteria.Evaluator function signature
Evaluators must:-
Accept keyword arguments:
input,output,expected_output,metadata -
Return a Langfuse
Evaluationobject withname,value(score), and optionalcomment
Configuration
Theevals_config.yaml file defines which agents to evaluate, their datasets, and evaluators.
Configuration structure
evals_config.yaml
Dataset format
Datasets are CSV files stored inevals/datasets/.
CSV structure
Example datasets
- Basic Q&A
- With Metadata
- Input Only
qa_dataset.csv
Running evaluations
Using the CLI
Using Python
How it works
The following diagram shows the evaluation framework flow:-
Discover tasks and evaluators. The framework automatically imports
evals.agentsandevals.evaluatorsmodules to discover registered functions. - Manage datasets. For each agent, the framework checks if the dataset exists in Langfuse. If not, it uploads the CSV file automatically.
- Run the experiment. The framework calls the task function for each dataset item and captures the results as Langfuse traces.
- Evaluate the results. Each evaluator runs on the task output, and the framework logs scores to Langfuse.
Troubleshooting
Task not found error
Task not found error
Error:
ValueError: Task 'my_agent' is not registeredCause: Task name in config doesn’t match the @register_task decorator.Solution: Ensure names match exactly:Dataset CSV not found
Dataset CSV not found
Error:
FileNotFoundError: CSV file not found at default pathCause: The CSV file doesn’t exist at the expected location.Solution: Ensure the CSV file exists at evals/datasets/{dataset_name}.csv:Evaluator not found
Evaluator not found
Error:
ValueError: Evaluator 'my_evaluator' is not registeredCause: Evaluator name in config doesn’t match the @register_evaluator decorator.Solution: Ensure names match exactly in evaluators.py and the configuration file.Langfuse credentials error
Langfuse credentials error
Error: Or in
ValueError: Langfuse credentials not configuredSolution: Set environment variables:.env file:.env
Empty results in Langfuse
Empty results in Langfuse
Cause: Task function returning
None or empty string.Solution: Ensure your task function returns a valid string:Next steps
Observability
Learn about tracing and monitoring your agents
AI Gateway
Connect to AI models through the gateway
CI/CD workflows
Integrate evals into your deployment pipeline
Starter kits
See evals integrated in production-ready templates