Skip to content

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

Draft
imohammedansari wants to merge 1 commit into
mainfrom
monocle-test-tools
Draft

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

Conversation

@imohammedansari

@imohammedansari imohammedansari commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a behavioral test suite that asserts against Open Deep Research's Monocle execution traces: which agent ran, what it was asked, what it returned, and its token and duration cost. Additive only, under tests/monocle/, with no app-code changes.

Why

The repo's existing tests are evaluation harnesses that score final reports over a benchmark with LangSmith and LLM judges. They exercise output quality, not what a real agent run actually did: which agent handled the request, what it returned, and what it cost. This adds that behavioral coverage, so if a later prompt, model, or route change alters routing, output, 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, contains_output / contains_any_output, under_token_limit, under_duration. The live test drives the real agent 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 offline tests and the live test here share the same fluent assertions for exactly this reason.

Open Deep Research runs its search inside the model call (OpenAI-native web search), so its traces carry no agentic.tool spans; behavior is validated through the agent invocation, the output, and the workflow budget.

Changes (all under tests/monocle/)

  • test_opendeepresearch.py: 4 offline file-loaded tests, one per curated question (Earth's seasons, renewable vs nonrenewable energy, ocean tides, TCP vs UDP), plus 1 live test (TCP vs UDP, guarded by OPENAI_API_KEY).
  • conftest.py: Monocle setup, .env loading, run_opendeepresearch().
  • traces/: 4 recorded traces, one per question.
  • requirements.txt, README.md.

imohammedansari added a commit that referenced this pull request Jul 8, 2026
1 offline fluent test (only one recorded trace) + 1 live test. OpenAI-native search (no separate tool spans); asserts agent + output + token/duration budgets. Hallucination eval deferred.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@imohammedansari imohammedansari changed the title Add Monocle Test Tools for cleaner tests (WIP) Add behavioral test coverage for the agent using Monocle Test Tools Jul 8, 2026
@imohammedansari imohammedansari changed the title Add behavioral test coverage for the agent using Monocle Test Tools Add Monocle behavioral test suite Jul 8, 2026
@imohammedansari
imohammedansari force-pushed the monocle-test-tools branch 3 times, most recently from 36c085b to b2b5f2a Compare July 9, 2026 20:14
@imohammedansari imohammedansari changed the title Add Monocle behavioral test suite Add trace-based behavioral tests with Monocle Test Tools Jul 9, 2026
@imohammedansari
imohammedansari force-pushed the monocle-test-tools branch 2 times, most recently from 27e80ca to e23128d Compare July 9, 2026 22:52
Trace-based tests under monocle-test/ asserting against the agent's Monocle execution traces (agent, tools, output, 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