Skip to content

Add trace-based behavioral tests with Monocle Test Tools - #32

Open
imohammedansari wants to merge 1 commit into
qx-labs:mainfrom
imohammedansari:monocle-test-tools
Open

Add trace-based behavioral tests with Monocle Test Tools#32
imohammedansari wants to merge 1 commit into
qx-labs:mainfrom
imohammedansari:monocle-test-tools

Conversation

@imohammedansari

@imohammedansari imohammedansari commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Adds a behavioral test suite that asserts against this deep-research agent's Monocle execution traces: which agents ran, what the run was asked, what it produced, and its token and duration cost. Additive only, under tests/monocle_test/, with no app-code changes.

Why

The existing tests exercise the framework, not what a real run actually did: which agents handled the request, what it produced, and what it cost. This adds that behavioral coverage, so if a later prompt, model, or pipeline change alters agent routing or token cost, a test catches it.

How it works

It uses Monocle Test Tools. The offline tests load a recorded trace from file with with_trace_source("file", trace_path=...), which is fast, needs no keys, and is deterministic. They then assert with the fluent API: called_agent, called_agents, does_not_call_agent, contains_input / contains_output, under_token_limit, under_duration. The live test drives the real multi-agent pipeline end to end and asserts on structure and budget only.

The point of loading from file is that the same assertions run in both modes. You pin a check against a recorded trace while iterating (fast, no keys, deterministic), then run the identical check against a live run for real regression coverage.

The OpenAI Agents SDK pipeline emits no agentic.tool spans (the web reach-out is modeled as a WebSearchAgent invocation), so behavior is validated through which agents ran plus the input, output, and budget.

Changes (all under tests/monocle_test/)

  • test_openaiagents.py: 4 offline file-loaded tests, one per curated question (quantum-computing survey, intermittent-fasting health review, grid-scale energy storage, Mediterranean-diet cardiovascular), plus 1 live test (carbon capture, guarded by keys).
  • conftest.py: Monocle setup, .env loading, run_openaiagents().
  • traces/: 4 recorded traces, one per question.
  • requirements.txt, README.md.

PS: if Monocle looks useful, a ⭐ helps the project (https://github.com/monocle2ai/monocle). The instrumentation that emits these traces is the companion PR (#31).

Trace-based behavioural tests for the deep-research agent using Monocle Test
Tools. Four offline tests replay recorded good traces (one per research
question) and one live test drives the agent end-to-end; each asserts which
agents ran, the request/response, and the token/duration budget.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant