Repository navigation
[fix-benchmark] Avoid rescanning semantic traces - #10
Conversation
- track semantic trace event counts in process - preserve retrieval LLM-call guards without reading historical JSONL - cover Zep and Mem0 benchmark driver behavior Signed-off-by: Von <haodong.lu.me@gmail.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe tracing module now counts events in process by trace root and event type. Evaluation drivers query these counts instead of parsing ChangesTrace Event Counting
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to The change is a localized benchmark accounting optimization with no actionable merge-blocking risk remaining after normal checks and review. Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/settings/billing. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
The new module-global in-process trace counters are never pruned, which can lead to unbounded growth and incorrect counts if a trace directory is deleted/recreated within the same process.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR optimizes benchmark trace accounting by switching semantic trace event counting from repeatedly rescanning events.jsonl files to maintaining in-process counters, while keeping the existing “no generative LLM call during retrieval” guards for the Zep and Mem0 benchmark drivers.
Changes:
- Add in-process trace event counting in
agent_memory.tracing.semanticand increment counts on each appended event. - Update benchmark driver trace-count helpers to use the in-process counter instead of JSONL rescans.
- Adjust and extend tests to validate the new counting behavior and ensure historical/malformed trace files are not scanned.
File summaries
| File | Description |
|---|---|
| tests/test_mem0_benchmark_integration.py | Updates Mem0 enhanced driver integration test to emit trace events via write_trace_event. |
| tests/test_agent_memory_benchmark_drivers.py | Updates trace-guard tests to use write_trace_event and adds coverage that retrieval does not parse historical/malformed JSONL. |
| src/agent_memory/tracing/semantic.py | Introduces _TRACE_EVENT_COUNTS and trace_event_count, and increments counts during _append_event. |
| src/agent_memory/evaluation/agent_memory_drivers.py | Replaces JSONL rescans for generative/provider usage counts with trace_event_count. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Scope
This is a single follow-up commit based directly on the latest
main. It does not include any local unstaged or untracked work from the semantic-pair branch.Verification
Summary by CodeRabbit
Performance
Bug Fixes
Reliability