Skip to content

feat(cache-warming): Warm after a Turn that ends with noReply - #3162

Merged
BYK merged 2 commits into
mainfrom
feat/cache-warming-no-reply
Nov 11, 2026
Merged

BYK merged 2 commits into
mainfrom
feat/cache-warming-no-reply

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Cause: a noReply call ends the run after its tool batch. An idle period starts only from a final response (stopReason: "stop"), so a Turn that ends with noReply never starts one. Its next Turn writes the whole prefix again.

Change:

  • When noReply ends the run, the agent marks this on the cache warming recorder. stop() then starts the normal idle period from the request that called noReply: same snapshot, segment, work state, parent prior and system prompt check. The gap is recorded on return like any other.
  • An Automation run (gated Turn) that ends with noReply starts no idle period, because an ended run almost never gets a reply. Since feat(automations): Answer Automation runs with reply, noReply and reportBlocked #3145, noReply replaces finishAutomationRun in Automation runs, so the gate is behavior.gated.
  • The recorder now remembers the last finished call before it skips mid-Turn calls. This way the snapshot is the noReply request even when earlier calls came first in the Turn.
  • New attribute app.cache_warming.turn_ending (reply or no_reply) on the cache_warming.warmup span and the cache_warming.conversation.returned log, so reports can group warmups, skips and returns by it.

Prefix: the snapshot is the input of the noReply request, and that request wrote or read the cache for it. Next Turn's input adds the noReply call, its result and the new message to that input. History keeps noReply calls unchanged, so the warmup refreshes the same prefix that the next Turn reads. A final response works the same way.

Before merge: check the gain against the 11-17 full-week backtest.

No UI change.

via @BYK.

--

View Session [Sentry]

A noReply call stops the run after its tool batch, so no final response
starts an idle period. Start it from the request of the noReply call,
outside Automation runs. Add app.cache_warming.turn_ending (reply or
no_reply) to the warmup span and the returned log.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 11, 2026 9:42am UTC

Request Review

@BYK
BYK marked this pull request as ready for review November 11, 2026 09:13
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

13 screenshot changes — 13 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Show 7 more changed screenshots
Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Question Picks And Text · Desktop
Conversation Question Picks And Text · Desktop
Changed
Conversation Stop Active · Mobile
Conversation Stop Active · Mobile
Changed
Conversation Text Attachment · Desktop
Conversation Text Attachment · Desktop
Changed
Conversations Sections Collapsed · Desktop
Conversations Sections Collapsed · Desktop
Changed
Memories · Mobile
Memories · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK enabled auto-merge (squash) November 11, 2026 09:40
…-reply

Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	packages/junior/src/chat/cache-warming/warmup.ts
@BYK
BYK merged commit 3bb0f4b into main Nov 11, 2026
45 checks passed
@BYK
BYK deleted the feat/cache-warming-no-reply branch November 11, 2026 09:48
BYK added a commit that referenced this pull request Nov 11, 2026
**Cause.** A run that ends with `reportBlocked` stops right after that
tool batch, as `noReply` does. No final response comes, so the Turn
starts no idle period. A child agent that ends blocked never warms, even
though its parent often answers.

**Change**
- The recorder method `noReplyEnded()` becomes
`answerToolEnded(toolName, gated)`. The agent calls it for every answer
tool that ends the run. The recorder maps the core tool names: `noReply`
gives `no_reply`, `reportBlocked` gives `blocked`. Gated Automation runs
still start no idle period. The decision now lives in the recorder, so
the scenario test covers it.
- `stop()` starts the idle period from the `reportBlocked` request, the
same way it does for `noReply` (#3162). That request holds the prefix
that the next Turn reads: the next request appends the assistant tool
call, its result and the new input to it.
- `app.cache_warming.turn_ending` gets a new value, `blocked`. That
keeps `no_reply` meaning `noReply` only. It is documented in the
`runCacheWarmup` JSDoc.

**Tests** (`cache-warming-segments.test.ts`): the #3162 case now runs
for both `noReply` and `reportBlocked`.
- A gated run schedules nothing.
- A non-gated run schedules a warmup and records the return gap.
- Without the `reportBlocked` mapping, the `reportBlocked` case fails.

No UI change.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A062fdc35bb40fd08d6b121c930cdc7fb -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A062fdc35bb40fd08d6b121c930cdc7fb)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A062fdc35bb40fd08d6b121c930cdc7fb/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 2ffaf06e Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant