Repository navigation
fix(compaction): share model-aware memory maintenance budgets - #130072
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 26, 2026, 7:10 AM ET / 11:10 UTC. ClawSweeper reviewWhat this changesCentralizes model-aware reserve and maintenance-threshold calculations so memory flushing and preflight compaction work on small-context models. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The small-context maintenance defect is real, but this patch also changes the exported memory-plugin contract by overriding provider-supplied thresholds; that compatibility policy needs an explicit maintainer choice before merge. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe embedded agent runner and the Gateway’s memory-maintenance path use a model context budget to decide when to compact or flush session memory. Their decisions affect whether important transcript context is saved before the next model request. flowchart LR
A[Model context window] --> B[Effective reserve]
C[Memory plugin plan] --> B
B --> D[Maintenance threshold]
E[Session token estimate] --> D
D --> F[Preflight compaction]
D --> G[Memory flush]
Decision needed
Why: The current public SDK exports this plan shape and current main honors its values verbatim; choosing host ownership versus plugin ownership changes existing plugin behavior. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +44. Total +56 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Add an explicit, backwards-compatible opt-in for model-aware budget normalization, enable it for the bundled Memory Core plan, preserve unmarked external plan values, and cover both paths. Do we have a high-confidence way to reproduce the issue? Yes in source: on current main an 8k context with the built-in 20k reserve produces no token gate, while the PR derives a 2k threshold; execution was not run in this read-only review. Is this the best way to solve the issue? No: shared normalization is the right direction for the bundled default, but unconditionally capping exported plugin plans changes their established runtime meaning; use an explicit opt-in boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e69b076e8bd1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
616404b to
ec93902
Compare
|
Merged via squash.
|
…aw#130072) * fix(compaction): share model-aware memory maintenance budgets * fix(compaction): remove dead exports and trim session fixture * fix(compaction): preserve plugin-owned maintenance budgets
Related: #124911.
What Problem This Solves
Fixes an issue where users of 8k, 16k, and 24k context-window models could silently miss memory flushing and preflight compaction because those paths subtracted a fixed 20k reserve even though the actual agent runner correctly capped that reserve for the selected model.
Why This Change Was Made
Consolidate the effective compaction-reserve calculation at its architectural owner and reuse it in embedded agent settings, preemptive compaction, memory-flush gating, preflight compaction, and threshold diagnostics. Bound soft maintenance headroom against the remaining usable prompt budget while preserving established reserve behavior for large-context models. No retired compaction configuration is restored.
User Impact
Small-context models preserve important history before overflow, compaction and memory flushing agree on the same thresholds, and existing large-model behavior remains unchanged.
Evidence