Skip to content

About

Tests for AI agents that run in CI: tool calls, arguments and repeated runs, traced with open-source Opik.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

agent-testing-recipes

Tests for AI agents that you can drop into CI. Each folder is one recipe, written up as a post on comet.com, and every recipe tests the same small refund agent in shared/refund_agent. Traces and experiments go to Opik, which runs locally in Docker. No account needed.

Folder What it tests Framework Post
01-langgraph-tool-calls The agent calls the right tool with the right arguments, on every run LangGraph LangGraph post
02-typescript-tool-calls The same tests in TypeScript, plus what the agent does when a tool throws OpenAI Agents SDK (TypeScript) TypeScript post
03-switching-models What changes in the agent's tool calls when you switch models LangGraph Coming soon

The agent

shared/refund_agent is a support agent for a made-up outdoor store, built with langchain.agents.create_agent. It has four tools: lookup_order, refund_order, search_help_center and escalate_to_human. The refund policy (30 days from delivery, and an order already marked refunded can't be refunded again) is checked in code, so a refund the policy forbids is refused even if the model asks for it. The tools don't remember refunds made during a conversation, so a second refund of the same order goes through; the tests catch that instead. The store data is fixed:

| Order | State | Refund allowed | |---|---|---|---| | A1001 | delivered 6 days ago | yes | | A1002 | in transit | no | | A1003 | delivered 45 days ago | no | | A1004 | delivered 30 days ago (last day) | yes | | A1005 | already refunded | no | | Z9999 | doesn't exist | no |

build_agent() uses Claude Sonnet 5.5 through langchain-anthropic, with tool_choice left at auto and strict tools. build_agent(model) takes any LangChain chat model that supports bind_tools.

Setup

Python 3.11 or newer, uv, Docker, and an Anthropic API key.

git clone https://github.com/comet-ml/agent-testing-recipes
cd agent-testing-recipes
uv sync

# Open-source Opik on localhost:5173 (the first start pulls the images)
git clone --branch 2.2.155 https://github.com/comet-ml/opik.git ../opik
OPIK_VERSION=2.2.155 ../opik/opik.sh
export OPIK_URL_OVERRIDE=http://localhost:5173/api

export ANTHROPIC_API_KEY=...

Set OPIK_URL_OVERRIDE in every shell you run the recipes from. Without it (or an Opik config file), the SDK points at Comet's cloud and asks for an API key. uv run opik configure --use_local --yes writes a config file instead, but it gives up if Opik takes more than a second to answer its health check, which happens while Opik is busy. To log to an Opik you already run, or to a free Comet account, run uv run opik configure.

Each recipe's README has its own commands.

Tested with

Python 3.12.13, langgraph 1.2.24, langchain 1.5.2, langchain-core 1.8.4, langchain-anthropic 1.7.12, opik 2.2.155 (SDK and local server), on November 23, 2026. Versions are pinned in pyproject.toml and uv.lock.

License

Apache 2.0

About

Tests for AI agents that run in CI: tool calls, arguments and repeated runs, traced with open-source Opik.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages