Skip to content

[fix-benchmark] Avoid rescanning semantic traces - #10

Merged
SleepyLGod merged 1 commit into
mainfrom
codex/avoid-semantic-trace-rescan
Aug 28, 2026
Merged

SleepyLGod merged 1 commit into
mainfrom
codex/avoid-semantic-trace-rescan

Conversation

@SleepyLGod

@SleepyLGod SleepyLGod commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • track semantic trace event counts in process instead of rescanning growing JSONL files
  • preserve retrieval LLM-call guards for Zep and Mem0 benchmark drivers
  • keep benchmark outputs and accounting semantics unchanged

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

  • targeted regression coverage for Zep and Mem0 trace-count behavior
  • Python 3.12/3.13 quality workflows and DCO are expected to run in CI

Summary by CodeRabbit

  • Performance

    • Improved trace event counting for faster usage and retrieval metrics.
  • Bug Fixes

    • Retrieval now safely ignores malformed historical trace data.
    • Missing trace directories are handled without errors.
  • Reliability

    • Trace event counts remain synchronized as events are recorded.

- 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>
Copilot AI lite review requested due to automatic review settings August 28, 2026 17:08
@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 6a5136a0-aaf3-4701-a47d-4bb94e54f25f

📥 Commits

Reviewing files that changed from the base of the PR and between 042c833 and d1dd459.

📒 Files selected for processing (4)
  • src/agent_memory/evaluation/agent_memory_drivers.py
  • src/agent_memory/tracing/semantic.py
  • tests/test_agent_memory_benchmark_drivers.py
  • tests/test_mem0_benchmark_integration.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The tracing module now counts events in process by trace root and event type. Evaluation drivers query these counts instead of parsing events.jsonl. Tests use write_trace_event and cover malformed historical trace data.

Changes

Trace Event Counting

Layer / File(s) Summary
Synchronized trace event counters
src/agent_memory/tracing/semantic.py
Adds trace_event_count and an in-process counter. Event appends update the counter under the existing write lock.
Evaluation driver count integration
src/agent_memory/evaluation/agent_memory_drivers.py, tests/test_agent_memory_benchmark_drivers.py, tests/test_mem0_benchmark_integration.py
Drivers query selected event counts. Tests emit structured provider-usage events and verify that malformed historical trace files are not scanned.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to d1dd4

The change is a localized benchmark accounting optimization with no actionable merge-blocking risk remaining after normal checks and review.


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.semantic and 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.

Comment thread src/agent_memory/tracing/semantic.py
@SleepyLGod SleepyLGod self-assigned this Aug 28, 2026
@SleepyLGod SleepyLGod added enhancement New feature or request feature labels Aug 28, 2026
@SleepyLGod
SleepyLGod merged commit dc4294f into main Aug 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants