Skip to content

fix(agent): a cut background job shows its whole run when it fits - #464

Merged
mrnasil merged 2 commits into
mainfrom
perf/bg-reread-cleaned-log
Nov 25, 2026
Merged

mrnasil merged 2 commits into
mainfrom
perf/bg-reread-cleaned-log

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Why

A background job keeps its last 64 KB of output in memory. A long run (e.g. a test suite printing 4,000 lines) lost its head: the model saw [earlier output dropped past 64 KB; full log: read proc://bg-1] and then test case_1047 ... ok. The first error or setup line was gone unless it read the log.

What

The whole output is already on disk in .whycodes/scratch/<id>.log. When a job ends with its tail cut:

Unchanged: a log that reached MAX_JOB_LOG_BYTES (its end is missing), a log still over 64 KB once cleaned, a missing log, a job that was never cut.

Measured (bench_tokens.py, release)

Request 6 now starts at the command's first line (test case_1 ... ok / [3998 similar lines…] / test case_4000 ... ok) instead of a dropped-head notice. Size is the same (16,199 → 16,176 tokens): this restores content, it does not add any.

Checks

  • cargo test -p whycodes-agent --lib (770 pass; new test covers restored / never cut / no log / too big / at cap / missing)
  • fmt, clippy (agent), panic / swallowed-error / dependency / secrets ratchets

🤖 Generated with Claude Code

mrnasil and others added 2 commits November 25, 2026 03:21
Background job output is kept in memory as its last 64 KB, so a long run
lost its head (the first error, the setup lines). The full output is on
disk in the job's scratch log. When a job ends with its tail cut, the log
is re-read and cleaned; if that fits in 64 KB (repeated and similar lines
fold), it replaces the tail. A log that hit its own cap, or still does
not fit, leaves the tail as before.

bench_tokens.py request 6 now starts at the command's first line instead
of "[earlier output dropped past 64 KB]" + case_1047, at the same size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit 8af28ce into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/bg-reread-cleaned-log branch November 25, 2026 00:37
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant