fix(session): make SessionConfig.compaction match runtime behavior - #161
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #158.
Summary
SessionConfig.compactionwas 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 —maybeCompactacceptingPartial<CompactionSettings>andSession.#runCompactionthreadingthis.#config.compactionthrough — already landed on main. This PR finishes the remaining items.src/index.ts— widencompaction?toPartial<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 assertingenabled: falsesuppresses compaction even when the threshold is crossed. Parallel to the existingcontextWindow-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 failbun test test/compaction.test.ts test/session.test.ts test/tracing.test.ts— 111 pass, 0 failbunx tsc --noEmit— cleanbunx biome checkon changed files — clean🤖 Generated with Claude Code