feat(compaction): optional compaction.model override + re-enable senpi compaction on SDK-native claude-sdk-oauth lanes - #737
Open
HeiTuz wants to merge 1 commit into
Conversation
…i compaction on SDK-native claude-sdk-oauth lanes
The claude-sdk-oauth lane keeps a resident Claude Agent SDK session, and the
lane policy stands down senpi compaction entirely because the SDK is supposed
to run its own native compaction. In practice that native compaction never
fires, so these sessions grow unbounded until the context overflows with no
recovery path.
Add a "compaction.model" setting ("provider/model") that redirects only the
compaction summarization call to a different model. When it is set:
- the lane policy's SDK-native stand-down lifts, so senpi auto/threshold
compaction runs on the lane again;
- _executeCompaction resolves the override model (via the model runtime) and
uses it for the summarization auth + compact() call, while session
bookkeeping (lifecycle record, preparation, branch) still tracks the session
model;
- any resolution failure (unset / malformed / unknown model) falls back to the
session model so compaction never silently breaks.
This gives the claude-sdk-oauth lane an escape hatch (e.g. compact on
deepseek/deepseek-chat) without changing default behavior for any provider.
Tests: lane-policy stand-down lift + no-override stand-down, settings
passthrough. Full compaction suite green (339 tests), typecheck clean.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Problem
The
claude-sdk-oauthlane keeps a resident Claude Agent SDK session, and the compaction lane policy (lane-policy.ts) stands down senpi compaction entirely on the assumption that the SDK runs its own native compaction. In practice that native compaction never fires for these sessions — senpi'ssession.logshowsthreshold/pre_promptcompactions repeatedly rejected withthe Claude Agent SDK owns compaction for this sessionwhile context grows unbounded (observed past 335k tokens) until overflow, with no recovery path.Change
Add an optional
compaction.modelsetting ("provider/model", e.g.deepseek/deepseek-chat) that redirects only the compaction summarization call to a different model. When set:lane-policy.ts): the SDK-native stand-down lifts, so senpi auto/threshold compaction runs on the lane again. This is the escape hatch for lanes whose SDK never compacts.agent-session.ts→_executeCompaction): a new_resolveCompactionModel()resolves the override through the model runtime and uses it for the summarization auth (_getCompactionRequestAuth) +compact()call. Session bookkeeping (lifecycle record, preparation, branch) still tracks the session model, so history/diagnostics are unaffected.provider/model/ unknown model) falls back to the session model, so compaction can never silently break.Default behavior is unchanged for every provider — with no override, nothing changes.
Surface
CompactionSettings.model?: string(settings-manager.ts,compaction/compaction.ts), exposed throughgetCompactionSettings().LaneContextgains an optionalgetCompactionSettingsgetter so the lane policy can read the override.Validation
modelpassthrough.test/compaction/suite: 47 files / 339 tests pass.npm run check(biome + pinned-deps + ts-imports + shrinkwrap +tsc --noEmit): clean.Summary by cubic
Adds an optional
compaction.modeloverride that redirects only the compaction summarization call to a specified model and re-enables senpi compaction onclaude-sdk-oauthlanes when set. Prevents unbounded context growth when SDK-native compaction never fires, with no change to default behavior when unset.compaction.modelaccepts "provider/model" (e.g.,deepseek/deepseek-chat); used only for summarization and falls back to the session model if invalid or unresolved.claude-sdk-oauthlanes, senpi auto/threshold compaction runs again instead of standing down.getCompactionSettings()and resolved at execution time without affecting session bookkeeping or diagnostics.Written for commit 95f7dfb. Summary will update on new commits.