feat(compaction): optional compaction.model override + re-enable senpi compaction on SDK-native claude-sdk-oauth lanes - #737
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. |
|
Another production datapoint for the "native compaction never fires" claim, from a lane that ran to the window edge rather than to 335k. Session: Prompt tokens ( 983,261 / 1,000,000 = 98.3% of the context window. senpi's adaptive threshold for a 1M window is Two details that may be worth folding into the fix:
One question on the shape of this PR: since the stand-down only lifts when |
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.