Repository navigation
[NO-JIRA] Cache-miss breaker for Gemini delegates on the state machine (R22) - #28
Merged
Merged
Conversation
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 06:16
0a6b40a to
dbaade8
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 08:18
dbaade8 to
7f7dd4f
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 09:06
7f7dd4f to
4357c93
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 10:16
4357c93 to
7a66a91
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 11:06
7a66a91 to
c670ae6
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 11:56
c670ae6 to
72cdf0a
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
…ont and rearm a text-only trip when the next step's cache hits An empty first response sends only usage, which latched the learned order to usage-first and let one more full-price call through. After a text-only trip, the next step's tool request no longer commits to stopping before its usage says whether the cache recovered. The stop outcome mapping moves into the fork module. X-Shepherd-Wake: #28
johnnymo87
force-pushed
the
r22-cache-miss-breaker
branch
from
November 22, 2026 12:36
72cdf0a to
b781b8f
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…che stopped hitting Port of patch 22 (fork #17) onto v1.60.2. The breaker module carries (fork-only agents/cache_miss_breaker.rs; usage fields are i64 now). Only the state-machine hook survives: ForegroundSubagentRunner::run_to_end observes the delegate's AgentEvent stream with a child cancel token, so a trip stops the delegate without touching its parent, and a breaker stop is reported with the delegate's last output. The legacy get_agent_messages half is gone with the legacy loop. Rule unchanged: 10 consecutive calls at >=50K prompt tokens with zero cache reads, on a Gemini model that has reported a hit in this process; a final answer on the trip step is let through. GOOSE_CACHE_MISS_BREAKER=off disables it. X-Shepherd-Wake: #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This ports patch 22 (fork #17) onto v1.60.2. It is bead workstation-6w7i.26.4.9 (R22). It should land after the cutover.
Vertex sometimes stops serving one session from its prompt cache, so every call re-reads the whole context at full price. The breaker stops a Gemini delegate when that happens, and its lead re-dispatches the work once as a new delegate.
GOOSE_CACHE_MISS_BREAKER=offturns it off.agents/cache_miss_breaker.rs. Only its state-machine hook remains:ForegroundSubagentRunner::run_to_endwatches the delegate's event stream using a child cancel token. A trip stops the delegate without cancelling its parent and reports the delegate's last output. The legacy-loop half went away with the legacy loop.Tests: 16 exact tests, added to
patched-test.yml. Three of them are end-to-end through the real state machine with a pinned fakegcp_vertex_aiprovider: it stops, it lets a final answer through, and it does nothing when off. The stop test fails without the hook. Clippy (-p goose --all-targets -D warnings) is clean.This PR also edits
run_to_end, as R16 (#26) does. It will be rebased after that merges.References