fix: each flush writes a separate partial bundle

Open
#5 1 comment 0 reactions 0 assignees View on GitHub

@kushaldave002 is already working on this.

Since Nov 19, 2026.

  • #16 by @kushaldave002 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, data

Research direction

Start in src/agenttrace/tracer.py at AgentTracer.flush and trace how end_session writes the session bundle. Add a test that flushes, records more events, then calls end_session; confirm it produces one file containing every event and that verify passes.

Written by the indexing model from the issue text.

Description

bug help wanted

AgentTracer.flush in src/agenttrace/tracer.py builds a new file name from the current time on every call and writes all events so far, so two flushes leave two overlapping bundles, and two flushes in the same second write to the same name. Pick the bundle path once per session and append only the events not yet written, so end_session finishes the same file. A test should flush, record more events, call end_session, and find one file that holds every event and passes verify.

Reproduced with:

$ cat flush_twice.py
import pathlib, time
from agenttrace import AgentTracer
t = AgentTracer(agent_id="a", output_dir="flushed")
t.start_session()
t.record_tool_call(tool="x")
t.flush()
time.sleep(1.1)
t.record_tool_call(tool="y")
t.end_session()
for p in sorted(pathlib.Path("flushed").glob("*.jsonl")):
    print(p.name, sum(1 for _ in p.open()), "events")
$ python flush_twice.py
agenttrace_ad5bf52a_1792794772.jsonl 2 events
agenttrace_ad5bf52a_1792794773.jsonl 4 events
Dominant language
Python
Stars
0
Forks
1
Avg merge
1d 10h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from obielin/agenttrace

All issues in obielin/agenttrace

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.