ITADN
obra/lace/Issues

feat(compact): default ent/session/compact strategy to summarize (PRI-1824)

#347Pull Requestobra 创建于 2026-05-25
O
obracommented
## Summary - Default `ent/session/compact` strategy from `'truncate'` to `'summarize'` in `packages/agent/src/rpc/handlers/session-operations.ts`. Truncate only crops TOOL_RESULT text blocks and reclaims ~10% of context on prose-heavy sessions, so the previous default was effectively a no-op for any caller that didn't pass `strategy` explicitly. - Adds regression tests at `packages/agent/src/rpc/handlers/__tests__/session-operations.compact-default.test.ts` covering both `{ }` and entirely-omitted params shapes; assertion spies on `setSystemPrompt(SUMMARIZER_SYSTEM_PROMPT)` which is only invoked on the summarize path. ## Rationale Evidence on Ada's main session (eventSeq 1581): a default-strategy call with `messagesCompacted:1166` left `preserved.length:1110` — essentially the same conversation with cropped tool outputs — and bounced back to 600K tokens within 12 turns. See [PRI-1824](https://linear.app/prime-radiant/issue/PRI-1824) and the strategy audit at `sen2/compaction/scratch/strategy-audit/` (and PRI-1819 comments) for full trajectory data. ## Callers audited All in-tree callers already pass `strategy` explicitly, so this only affects callers that were depending on the default — and they were depending on a no-op: - `sen-core-v2/src/turn-hooks/compaction-trigger.ts` — passes `'truncate'` or `'summarize'` - `sen-core-v2/src/rotation/runner.ts` — passes `'summarize'` - `lace/packages/agent/src/conversation/slash-commands.ts` — passes strategy via slash command - All test callers (`agent-process.e2e.test.ts`, `ent-protocol.spec.ts`, `session-operations.compact-budget.test.ts`, `session-operations.compact-prompt.test.ts`) pass strategy explicitly ## Coordination Independent of PRI-1825 (rename `truncate` → `trim-tool-results`). This change touches only the default value, not the wire enum names. If both land, the new default becomes `'summarize'` and the old `'truncate'` enum slot is renamed/removed by PRI-1825. ## Test plan - [x] `npm run typecheck --workspace=packages/agent` — clean - [x] `npm run build --workspace=packages/agent` — clean - [x] New tests fail RED on origin/main (verified before implementing fix) - [x] New tests pass GREEN with the change - [x] Compaction-related tests pass (40/40): `session-operations.compact-default.test.ts`, `session-operations.compact-prompt.test.ts`, `session-operations.compact-budget.test.ts`, `agent-process.e2e.test.ts` (compact truncate + compact summarize), `ent-protocol.spec.ts` (invalid strategy validation) - [x] Full agent suite: 2851 passed, 6 pre-existing failures (Apple container integration + session-fork.durable-history) confirmed present on origin/main — unrelated - [ ] `npm run lint --workspace=packages/agent` — 58 pre-existing errors on origin/main, none introduced by this change (verified by re-running lint on origin/main and on the two files touched by this PR)
合并状态:未合并 1 条评论