code-yeongyu / code-yeongyu/senpi
compaction: allow an explicitly configured compaction model/provider with safe fallback
- Dominant language
- TypeScript
- Stars
- 429
- Forks
- 98
- Avg merge
- 5h 3m
- Merged PRs (30d)
- 526
Description
## Problem
Compaction summary generation always uses the session model and its auth (`_getCompactionRequestAuth` -> session model). When the session model is native Cursor and the conversation is already under context pressure, the compaction request itself can fail with `resource_exhausted` (observed in session 01a01831: compaction tokensBefore ~4.2M, cursor/claude-fable-5-high, two compacts saved ~1% before the turn died).
PR # fixes the surrounding death spiral (threshold now samples the local transcript estimate, token-bearing `resource_exhausted` classifies as overflow, billed usage lands on `usage`), so compaction should now fire long before the context is hopeless. This issue tracks the remaining hardening.
## Proposal
Allow an explicitly configured compaction model/provider with a safe fallback:
- New optional compaction setting, e.g. `compaction.model: "provider/model"`, resolved through the normal model runtime + auth path.
- When configured and resolvable, compaction requests use that model; otherwise fall back to the session model (current behavior).
- No silent automatic provider switching: changing provider mid-compaction affects credentials, cost, and data-routing expectations, so only an explicit configuration may route compaction elsewhere, and a clear failure must surface when the configured model cannot be resolved.
## Notes
- Reviewer guidance from the report thread: prefer explicit configuration over an automatic cheaper-provider heuristic.
- Needs: settings schema + docs, auth resolution reuse, availability check, tests for configured/fallback/unresolvable cases.
Contributor guide
Research direction
Start with the compaction request path around _getCompactionRequestAuth, then trace the settings schema and normal model runtime/auth resolution. Check existing compaction and authentication tests before adding coverage for configured, fallback, and unresolvable cases. Done means the schema, documentation, availability behavior, and all three model-selection paths are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, authentication, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100