Context
`spawnLocalProcess` (`src/tools/local/LocalExecutionEngine.ts`) spills overflow output to a temp file when a child process exceeds `maxOutputChars * 2` bytes in memory. The path is reported back as `SpawnResult.fullOutputPath` so the model can read it later. The file is never cleaned up.
Over many agent turns with verbose commands (build logs, large test suites, `yes`-style runaways), `/tmp` accumulates stale `lc-local-output-*.txt` files. No registry, no TTL, no cleanup hook.
Flagged by a comprehensive code review as "MINOR" (#6 in their list) but worth tracking.
Why this is hard to fix inline
The spill file holds the full output the model is expected to read on a later turn — so we can't aggressively delete at end-of-tool-call. The right cleanup point is end-of-Run, but that requires:
- Tracking spill paths somewhere addressable from the Run lifecycle (currently each `SpawnResult` is fire-and-forget)
- A `Run.dispose()` / `Run.complete()` hook that fires regardless of how the Run terminated (success, error, abort)
- Probably a config knob so hosts that want to inspect spills post-Run can opt out of cleanup
Suggested approach
- Add a `spillRegistry: Set` on the Run (or on `LocalExecutionConfig` if we want it engine-scoped)
- `spawnLocalProcess` registers `spillPath` when it lazily opens the spill stream
- `Run.complete()` (or equivalent) iterates the set and `unlink`s each path; failures are logged but not thrown
- New config: `local.keepSpillFiles?: boolean` (default false). When true, no cleanup — host can grep `/tmp/lc-local-output-*` themselves.
Alternative: use a TTL via `tmp.file({ discardDescriptor: true })` if we adopt the `tmp` package; sweeps on process exit. Simpler but has a Node-specific dep.
Refs
Context
`spawnLocalProcess` (`src/tools/local/LocalExecutionEngine.ts`) spills overflow output to a temp file when a child process exceeds `maxOutputChars * 2` bytes in memory. The path is reported back as `SpawnResult.fullOutputPath` so the model can read it later. The file is never cleaned up.
Over many agent turns with verbose commands (build logs, large test suites, `yes`-style runaways), `/tmp` accumulates stale `lc-local-output-*.txt` files. No registry, no TTL, no cleanup hook.
Flagged by a comprehensive code review as "MINOR" (#6 in their list) but worth tracking.
Why this is hard to fix inline
The spill file holds the full output the model is expected to read on a later turn — so we can't aggressively delete at end-of-tool-call. The right cleanup point is end-of-Run, but that requires:
Suggested approach
Alternative: use a TTL via `tmp.file({ discardDescriptor: true })` if we adopt the `tmp` package; sweeps on process exit. Simpler but has a Node-specific dep.
Refs