← Back to PRs

#19232: fix(compaction): preserve exact identifiers in summarization

by brandonwise open 2026-02-17 15:09 View on GitHub →
agents size: S trusted-contributor
Fixes #19207 ## What Expands compaction summarization to preserve all exact identifiers, not just file paths, function names, and error messages. ## Why Users reported that UUIDs, IPs, commit SHAs, container hashes, and other precise identifiers were being truncated during compaction. The model would then hallucinate replacements, causing API failures and misconfigurations. ## How - Added `customInstructions` option to `AgentCompactionConfig` - Created `DEFAULT_COMPACTION_INSTRUCTIONS` with a comprehensive identifier preservation list - Applied default instructions to both automatic (overflow) and manual (`/compact`) compaction - Users can override via config if needed ## Testing - [x] Added unit tests for instruction resolution - [x] `pnpm check` passes (pre-existing TS2742 errors unrelated to this PR) - [x] `pnpm build` passes ## AI-Assisted 🤖 This PR was built with AI assistance (Claude via OpenClaw). - [x] Code reviewed and understood - [x] Lightly tested - [x] Session available on request <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds default compaction instructions to preserve exact identifiers (UUIDs, IPs, commit SHAs, container hashes, etc.) during session compaction summarization. The change is well-structured, adding a new `compaction-instructions.ts` module with a `resolveCompactionInstructions` helper that falls back to sensible defaults when no user override is provided. - Added `DEFAULT_COMPACTION_INSTRUCTIONS` with a comprehensive identifier preservation list - Integrated default instructions into both overflow (automatic) and manual (`/compact`) compaction paths - User-provided `/compact:` inline instructions correctly take precedence over defaults - Users can override via `agents.defaults.compaction.customInstructions` config (but see issue below) - **Issue**: The Zod validation schema in `src/config/zod-schema.agent-defaults.ts` was not updated to include `customInstructions`. The compaction schema uses `.strict()`, so user configs that set this field will fail validation with an unrecognized key error. The default instructions work fine since they don't require config, but the user-override path is broken. <h3>Confidence Score: 3/5</h3> - The default behavior works correctly, but the config override path is broken due to a missing Zod schema update. - The core feature (applying default identifier-preservation instructions to compaction) works as intended and is well-tested. However, the advertised user-override via config will cause validation errors because the Zod schema was not updated to match the new TypeScript type field. This is a functional gap that prevents users from customizing the instructions as documented in the type. - Pay attention to `src/config/types.agent-defaults.ts` — the `customInstructions` field needs a corresponding entry in `src/config/zod-schema.agent-defaults.ts`. <sub>Last reviewed commit: dc3a654</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs