fix: bound trajectory runtime flush#77154
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. source-level. Current main serializes runtime events before queueing and lets cleanup continue after the 10s timeout, and the PR blocker is also source-reproducible from the writer max-file no-op path. Next step before merge Security Review findings
Review detailsBest possible solution: Keep the bounded recorder/writer direction, but make the recorder or writer account for existing sidecar bytes and max-file skips before landing so the linked bug closes through this PR. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main serializes runtime events before queueing and lets cleanup continue after the 10s timeout, and the PR blocker is also source-reproducible from the writer max-file no-op path. Is this the best way to solve the issue? No, not as written. The bounded capture approach is the right maintainable direction, but it needs to treat max-file skips or pre-existing sidecar size as dropped capture before merge. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f0537e93fbe6. |
c1550b6 to
ae53d26
Compare
4a1add6 to
ceb110c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ceb110ce1f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const result = writer.write(jsonlLine); | ||
| if (result === "dropped") { | ||
| captureStopped = true; | ||
| droppedEvents += 1; | ||
| droppedEventBytes += lineBytes; |
There was a problem hiding this comment.
Treat max-file no-op writes as dropped during runtime capture
When a session’s runtime sidecar is already near maxRuntimeFileBytes (for example, later turns writing to the same session.trajectory.jsonl), writer.write can still return success even though the append is skipped by the writer’s max-file guard, and this branch counts it as accepted bytes. In that case captureStopped is never triggered by the real file-limit drop, so the recorder keeps sanitizing/serializing subsequent events and may never emit trace.truncated, which defeats the new “stop capture at 10 MiB” behavior under exactly the long-lived-session scenario this fix targets.
Useful? React with 👍 / 👎.
* fix: bound trajectory runtime flush * fix: keep trajectory export cap compatible * test: keep followup delivery test pure
* fix: bound trajectory runtime flush * fix: keep trajectory export cap compatible * test: keep followup delivery test pure
* fix: bound trajectory runtime flush * fix: keep trajectory export cap compatible * test: keep followup delivery test pure
* fix: bound trajectory runtime flush * fix: keep trajectory export cap compatible * test: keep followup delivery test pure
* fix: bound trajectory runtime flush * fix: keep trajectory export cap compatible * test: keep followup delivery test pure
Summary
recordEvent.trace.truncatedmarker, and keep queued file writes from growing beyond the same budget while yielding before sidecar appends.Closes #77124.
Verification
pnpm test src/agents/queued-file-writer.test.ts src/trajectory/runtime.test.ts src/trajectory/export.test.tspnpm check:changed:tbx_01kqs0dbsp3yy5k9cxgq5vc8jw, exit 0