#19232: fix(compaction): preserve exact identifiers in summarization
agents
size: S
trusted-contributor
Cluster:
Compaction Enhancements and Features
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
#11089: feat(compaction): support customInstructions and model override for...
by p697 · 2026-02-07
83.3%
#10456: fix: preserve persona and language continuity in compaction summaries
by keepitmello · 2026-02-06
79.8%
#20038: (fix): Compaction: preserve recent context and sync session memory ...
by rodrigouroz · 2026-02-18
79.2%
#21547: feat: add compaction.announce config to notify users of compaction ...
by jlwestsr · 2026-02-20
78.2%
#14021: feat(compaction): optional memory flush before manual /compact
by phenomenoner · 2026-02-11
77.8%
#8313: feat: auto-compaction support for spawned subagent sessions
by vishaltandale00 · 2026-02-03
75.9%
#19329: feat: add per-agent compaction and context pruning overrides
by curtismercier · 2026-02-17
75.7%
#8903: fix: improve compaction summary instructions to preserve active work
by joetomasone · 2026-02-04
75.6%
#10505: feat(compaction): add timeout, model override, and diagnostic logging
by thebtf · 2026-02-06
75.3%
#14887: feat(compaction): configurable auto-compaction notifications with o...
by seilk · 2026-02-12
75.3%