Skip to content

Cap tool output in session.json and redact nested items - #8

Merged
Darknode-Official merged 1 commit into
mainfrom
fix/session-bloat
Nov 1, 2026
Merged

Darknode-Official merged 1 commit into
mainfrom
fix/session-bloat

Conversation

@Darknode-Official

Copy link
Copy Markdown
Owner

Cap tool output in session.json and redact nested items

A long session's .nexus/session.json reached 90 MB (one tool result alone
was 15 MB), and every end-of-turn save re-serialized and rewrote all of it.

  • Saved copies of tool results keep the head and tail of anything over
    8 KB (1.5 KB for blocks older than the last 40), with a marker saying
    how much was trimmed. The live transcript keeps the full output.
  • Resuming an older, untrimmed session trims it on load.
  • Nested item fields (tool result/input/diff, text, thinking) are now run
    through the transcript redactor; only top-level strings were before.
  • Each saved item copy is cached until the item changes, so a save only
    processes new output.

On a copy of the 90 MB session: file 90 MB -> 34 MB, steady-state save
293 ms -> 140 ms (now including nested redaction). The first save after
a resume pays a one-time ~0.8 s to redact the restored history.

test/session-save.test.js covers the caps, nested redaction and caching.

A long session's .nexus/session.json reached 90 MB (one tool result alone
was 15 MB), and every end-of-turn save re-serialized and rewrote all of it.

- Saved copies of tool results keep the head and tail of anything over
  8 KB (1.5 KB for blocks older than the last 40), with a marker saying
  how much was trimmed. The live transcript keeps the full output.
- Resuming an older, untrimmed session trims it on load.
- Nested item fields (tool result/input/diff, text, thinking) are now run
  through the transcript redactor; only top-level strings were before.
- Each saved item copy is cached until the item changes, so a save only
  processes new output.

On a copy of the 90 MB session: file 90 MB -> 34 MB, steady-state save
293 ms -> 140 ms (now including nested redaction). The first save after
a resume pays a one-time ~0.8 s to redact the restored history.

test/session-save.test.js covers the caps, nested redaction and caching.
@Darknode-Official
Darknode-Official merged commit b1d77aa into main Nov 1, 2026
0 of 6 checks passed
@Darknode-Official
Darknode-Official deleted the fix/session-bloat branch November 1, 2026 01:18
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