Agents: skip redundant partial compaction summarization#61603
Conversation
Greptile SummaryThis PR fixes a redundant summarization pass in
Confidence Score: 4/5Safe to merge; the fix is logically correct and well-tested with a minor observability concern The strict-subset guard correctly prevents duplicate API calls when no messages are oversized. Both the fixed case and the regression case are covered by exact call-count assertions. The only issue is the warning log still says 'trying partial' even in the newly-skipped path, which is a minor inaccuracy in log messaging rather than a correctness bug. src/agents/compaction.ts lines 400-405 (warning log says 'trying partial' even when partial summarization will be skipped)
|
|
Addressed the current AI review feedback on this PR. What changed:
What I verified:
Follow-up commit: I did not find any other actionable AI review comments on the PR at the moment. |
b8bcaf3 to
69d551d
Compare
|
Landed via temp rebase onto latest Scoped verification:
Repo-wide note:
Thanks @neeravmakwana! |
Summary
summarizeWithFallbackstill ran a "partial" pass over the same transcript, duplicating failing API work (including retries) and the second warning log.fetch failed), this doubled load and log noise and worsened responsiveness during compaction.smallMessagesis a strict subset of the original messages (i.e. at least one oversized message was excluded).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
src/agents/compaction.summarize-fallback.test.tsgenerateSummaryis invoked only for the full path retries (3), not again for a duplicate partial pass. When one message is oversized, full and partial paths each run (6 total mock calls).User-visible / Behavior Changes
Diagram (if applicable)
N/A
Security Impact (required)
Testing
pnpm testonsrc/agents/compaction.test.ts,compaction.retry.test.ts,compaction.tool-result-details.test.ts,compaction.summarize-fallback.test.tsoxlinton touched TypeScript files