Repository navigation
[NO-JIRA] Cache-miss breaker: stop a Gemini delegate whose prompt cache stopped hitting - #17
Merged
Merged
Conversation
…he stopped hitting Vertex sometimes stops serving one session from its prompt cache, so every call re-reads the whole context at full price while concurrent sessions hit 97-99% (workstation-ke9f). A stuck session usually stays stuck; a fresh one gets a fresh chance. This ports opencode's cache-miss-breaker plugin (workstation#840) to goose delegates. Rule: 10 consecutive model calls at >=50K prompt tokens with zero cache reads (a hit resets; a smaller call neither counts nor resets), on a Gemini model that has reported a cache hit in this process. On trip, the trip step's response decides: a request for any tool other than recipe__final_output cancels the delegate (a child token, never the parent's) and fails it with a message telling the lead to re-dispatch once as a new delegate. A final answer is let through. It is a step observer over the delegate's AgentEvent stream, in both event loops: get_agent_messages (the legacy loop goose-serve runs today) and ForegroundSubagentRunner::run_to_end (state machine). agent.rs is untouched. GOOSE_CACHE_MISS_BREAKER=off disables it; GOOSE_CACHE_MISS_BREAKER_STEPS and GOOSE_CACHE_MISS_BREAKER_MIN_CONTEXT override the thresholds.
…to tool results, keep a delivered final output, re-arm on a hit
johnnymo87
added a commit
to johnnymo87/workstation
that referenced
this pull request
Nov 20, 2026
…k launch --effort (#878) #### Description - **goose → patched-1.54.0.16.** Adds two fork patches: the cache-miss breaker for Gemini delegates (johnnymo87/goose#17, workstation-6w7i.22) and a role recipe's `settings.thinking_effort` overriding the effort a delegate inherits from its lead (johnnymo87/goose#18). No session DB schema change. - **goose-roles:** every role recipe now sets `thinking_effort: high`. That keeps Gemini and Opus roles at high under a worker lead running at medium. The build now checks that the pinned goose knows the field: an older goose silently ignores it, so a bogus value must fail `goose recipe validate`. - **honk → 447fa5b:** `honk launch --effort <level>` sets a new session's thinking effort (johnnymo87/honk#38). stall-watch will launch goose workers with `--effort medium` in a follow-up, after this is live. Coordinators and every other goose session keep goose-serve's `GOOSE_THINKING_EFFORT=high`. - goose-serve does not restart on switch (restartIfChanged=false), so the new goose takes effect at the next goose-serve restart. #### References - workstation-6w7i.20, workstation-6w7i.22 (beads)
This was referenced Nov 21, 2026
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
…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
…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
…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
…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
…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
…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
…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 was referenced Nov 22, 2026
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
cache-miss-breakerplugin (Stop a Gemini subagent whose prompt cache stops hitting workstation#840) to goose delegates.recipe__final_output), the delegate is cancelled through a child token (never the parent's) and fails with a message telling the lead it is unfinished, to check the worktree, and to re-dispatch once as a new delegate ("re-dispatch [NO-JIRA] Add Apache-2.0 modification notices and fix the Nix dev shell build #1 after cache-miss breaker"), never a third time. It carries the delegate's last assistant text. A final answer is let through, and a final output delivered on the trip step is kept.agents/cache_miss_breaker.rs) over the delegate'sAgentEventstream in both delegate loops:get_agent_messages(the legacy loop goose-serve runs today; it stops before the 11th call, after the trip step's tools finished) andForegroundSubagentRunner::run_to_end(state machine; it waits for the trip step's tool results so no tool is killed mid-run). It works out per delegate whether the provider reports usage before or after a step's message.agent.rsis untouched.GOOSE_CACHE_MISS_BREAKER=offdisables it;GOOSE_CACHE_MISS_BREAKER_STEPS/_MIN_CONTEXToverride the thresholds.run_subagent_taskwith a provider stuck at 60K context and no cache reads, and checks that the delegate is stopped after exactly the trip call, that the lead's error says to re-dispatch, and that the parent token is untouched.cache_miss_breakeris added to the release workflow's test filter.usage_ledger(521 Gemini calls, 17 Gemini delegate sessions) has 0 would-be trips, so no false positives there. opencode's backtest found 10 trips in 1694 Gemini child sessions, all of them stuck sessions.subagent_handler.rsthere keepsForegroundSubagentRunner::run_to_endwith the sameevents.next()loop (overservices.run_subagent_turn), so the observer moves in unchanged, usingdeferring_to_tool_results(). Theget_agent_messageshook goes away, because upstream removed background subagents and the legacy loop.References