Add trace-based behavioral tests with Monocle Test Tools - #32
Open
imohammedansari wants to merge 1 commit into
Open
Add trace-based behavioral tests with Monocle Test Tools#32imohammedansari wants to merge 1 commit into
imohammedansari wants to merge 1 commit into
Conversation
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.
imohammedansari
force-pushed
the
monocle-test-tools
branch
from
July 9, 2026 23:34
6c5a2c6 to
b5f0954
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.toolspans (the web reach-out is modeled as aWebSearchAgentinvocation), 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,.envloading,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).