Problem#
A large conversation that waits on PR news can wake with a cold provider prompt cache and reread its whole history (#16829, #13988).
Change#
watch_pull_request gets an opt-in compactBeforeWaiting flag. Starting a new watch with it queues one native /compact turn after the current turn, or starts it right away on an idle conversation. The watch and the request commit together, and PR news that arrives in the meantime queues behind the compaction. Ordinary watches don't change, and a repeat call on an existing watch doesn't queue a second compaction.
Any provider with native compaction works. The request is rejected if the thread already has queued work, pending input or approval, unfinished maintenance, or an unsafe run state. In that case the agent is told to watch without compaction. If a question or approval arrives after opt-in, the queued compaction is dropped so the answer runs next. The user can cancel the queued compaction like any queued message.
This is a direction proposal and needs maintainer sign-off. Keepalives, budgets, and cache-TTL telemetry are out of scope.
Verification#
vp test run on PullRequestWatchCompaction.test.ts, the pull-request toolkit handlers.test.ts, pullRequestWatch.test.ts, and ThreadStop.test.ts: 60 passed.
- Server typecheck and targeted lint pass.
- Real-world cache savings and summary quality are not measured.
Model: Claude Opus 5.5 · Harness: Claude Code in T3 Code
Note
This comment is posted by Julius' dot
This adds a new workflow that queues compaction when starting a PR watch. The description and your follow-up in #13988 say direction approval is still pending; that issue's warm-cache offer discussion does not approve this watch-triggered workflow. Closing under the prior-approval requirement. Please get explicit maintainer approval for this scope and link it when requesting reconsideration.