Skip to content

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
code-yeongyu:mainfrom
HeiTuz:compaction-model-override
Open

feat(compaction): optional compaction.model override + re-enable senpi compaction on SDK-native claude-sdk-oauth lanes#737
HeiTuz wants to merge 1 commit into
code-yeongyu:mainfrom
HeiTuz:compaction-model-override

Conversation

@HeiTuz

@HeiTuz HeiTuz commented Aug 6, 2026

Copy link
Copy Markdown

Problem

The claude-sdk-oauth lane 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's session.log shows threshold/pre_prompt compactions repeatedly rejected with the Claude Agent SDK owns compaction for this session while context grows unbounded (observed past 335k tokens) until overflow, with no recovery path.

Change

Add an optional compaction.model setting ("provider/model", e.g. deepseek/deepseek-chat) that redirects only the compaction summarization call to a different model. When set:

  1. Lane policy (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.
  2. Execution (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.
  3. Safe fallback: any resolution failure (unset / malformed 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 through getCompactionSettings().
  • LaneContext gains an optional getCompactionSettings getter so the lane policy can read the override.

Validation

  • New tests: lane-policy stand-down lift with override + continued stand-down when the override resolves to no model; settings model passthrough.
  • test/compaction/ suite: 47 files / 339 tests pass.
  • Root npm run check (biome + pinned-deps + ts-imports + shrinkwrap + tsc --noEmit): clean.

Summary by cubic

Adds an optional compaction.model override that redirects only the compaction summarization call to a specified model and re-enables senpi compaction on claude-sdk-oauth lanes when set. Prevents unbounded context growth when SDK-native compaction never fires, with no change to default behavior when unset.

  • New Features
    • compaction.model accepts "provider/model" (e.g., deepseek/deepseek-chat); used only for summarization and falls back to the session model if invalid or unresolved.
    • Lane policy: when an override is set on claude-sdk-oauth lanes, senpi auto/threshold compaction runs again instead of standing down.
    • Setting is exposed via getCompactionSettings() and resolved at execution time without affecting session bookkeeping or diagnostics.

Written for commit 95f7dfb. Summary will update on new commits.

Review in cubic

…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.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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