Skip to content

fix(session): make SessionConfig.compaction match runtime behavior - #161

Merged
siripr4 merged 1 commit into
mainfrom
fix/158-compaction-settings-wiring
Apr 21, 2026
Merged

fix(session): make SessionConfig.compaction match runtime behavior#161
siripr4 merged 1 commit into
mainfrom
fix/158-compaction-settings-wiring

Conversation

@siripr4

@siripr4 siripr4 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Closes #158.

Summary

SessionConfig.compaction was a partially-wired public API: the type required all four fields, the docstring claimed compaction was off by default, and neither matched the runtime (on by default, one-field overrides are the natural use case). The runtime wiring itself — maybeCompact accepting Partial<CompactionSettings> and Session.#runCompaction threading this.#config.compaction through — already landed on main. This PR finishes the remaining items.

  • src/index.ts — widen compaction? to Partial<CompactionSettings> so { enabled: false } and individual-knob overrides type-check, and rewrite the docstring to describe actual behavior (on by default; unset fields fall back to built-in defaults).
  • test/compaction.test.ts — add a Session-level integration test asserting enabled: false suppresses compaction even when the threshold is crossed. Parallel to the existing contextWindow-flows-through test.
  • docs/src/content/docs/guides/configuration.md — restore the tunable-knobs example that was trimmed to "enabled by default" while this bug was open, with separate opt-out and threshold-override blocks and a when-it-fires note.

Test plan

  • bun test test/compaction.test.ts — 32 pass, 0 fail
  • bun test test/compaction.test.ts test/session.test.ts test/tracing.test.ts — 111 pass, 0 fail
  • bunx tsc --noEmit — clean
  • bunx biome check on changed files — clean
  • Eyeball the rendered Context Compaction section on the docs site after merge

🤖 Generated with Claude Code

Align the public SessionConfig.compaction type and docstring with how
compaction actually behaves. The wiring itself (maybeCompact settings
parameter + Session.#runCompaction passthrough) already landed; this
finishes the remaining items from #158:

- Widen the public type to Partial<CompactionSettings> so { enabled:
  false } and single-field overrides type-check. The stored config
  (session.config.compaction) is also Partial, so the shapes now match.
- Rewrite the docstring: compaction is on by default, opt out with
  { enabled: false }, individual fields fall back to built-in defaults.
- Add a Session-level integration test asserting enabled: false
  actually suppresses compaction when the threshold is crossed.
- Restore the tunable-knobs example in the configuration guide, with
  both opt-out and threshold-override patterns plus when-it-fires notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@siripr4
siripr4 merged commit 4551188 into main Apr 21, 2026
6 checks passed
@siripr4
siripr4 deleted the fix/158-compaction-settings-wiring branch April 21, 2026 08:16
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.

SessionConfig.compaction is accepted but ignored at runtime; docstring contradicts behavior

1 participant