agent-ops-patterns / gallery / goose map / how it decides
How goose decides
In an ordinary goose session, plain code runs a fixed list of steps around the AI model's calls, and a plain text reply with no tool request ends the turn when nothing else is set up. A goal (/goal or /grind), a recipe's checks or required output, or a plugin's stop hook can each cause more work before the turn ends.
How it decides it is done
-
The model stopped; has it delivered the recipe's final output, or must it be told to?
Decided by plain code Only for a recipe with a response schema: code looks since your kickoff message for a final-output call that succeeded. If there is one the turn may end; otherwise it adds a model-only message saying to call that tool now, and the agent continues.
final_output_tool.rs:55-95· decision G7 in the full map -
If a review pass or check crashed or returned garbage, does the review say so?
Decided by plain code On goose review's default path, a failed check or per-file pass adds no findings and a warning on stderr. If the review otherwise completes, it prints the findings that pass the severity floor and exits successfully.
orchestrator.rs:133-150· decision G10 in the full map -
When a subagent stops, did it complete, fail or get cancelled?
Decided by plain code After reloading its session, code checks in a fixed order: a successful final-output call means Completed, even if the run was cancelled or errored afterwards; else a cancelled run is Cancelled; anything else is Failed.
subagent_handler.rs:140-176· decision H4 in the full map
Limits and memory
-
Has the agent taken as many steps as it may without coming back to you?
Decided by plain code When this step is reached, code counts the assistant turns kept since your kickoff message; at the budget it ends the turn with a fixed "Would you like me to continue?" message. In an ordinary session the budget is the session's max_turns, else GOOSE_MAX_TURNS, else 1000.
ops_maxturns.rs:53-67· decision F8 in the full map -
Has the conversation grown big enough to summarise before the next model call?
Decided by plain code Code compares the conversation's tokens with the context limit and compacts above a threshold: by default 0.8 of the limit, or 225,000 tokens if that is less, and both are settings. A threshold of 0 or less, or 1 or more, turns this trigger off, and it is not built when the provider manages its own context.
ops_compaction.rs:218-227· decision F1 in the full map -
When the conversation is compacted, what is carried forward?
Decided by an AI model The session's own model writes the summary. If its reply parses as the structured summary and renders to non-empty text, that rendering is used; otherwise the raw reply is kept unchanged.
summarize.rs:124-182· decision F3 in the full map -
How long may a command from the developer shell tool run?
Decided by an AI model The model may pass a timeout with each call; if it does not, code uses a setting, else 300 seconds. A value of 0 means that tool sets no deadline.
shell.rs:408-440· decision E4 in the full map
Other judgments
-
When a resumed command-line session's original provider cannot start, what runs instead?
Decided by plain code Only on resume with no --provider flag, and only when the provider's error text contains one of three fixed phrases, code switches to the globally configured provider and model and prints a yellow warning. Any other provider error, or a failed fallback, exits.
builder.rs:908-913· decision A5 in the full map -
Can a subagent start subagents of its own?
Decided by plain code No. Code refuses a delegate call from a subagent session and does not list the tool to a session it identifies as a subagent, so delegation depth is fixed at one.
summon.rs:874-876· decision H3 in the full map -
Did a file edit find exactly the text the model meant to replace?
Decided by plain code Code counts exact occurrences of the model's before text: exactly one goes on to be replaced and written; zero or more than one returns an error and writes nothing. There is no fuzzy or whitespace-tolerant matching.
edit.rs:129-168· decision E12 in the full map
Three problems in the code
-
1. The --max-tool-repetitions flag has no effect
goose's help says this flag limits consecutive identical tool calls. At this commit it does not: the command line accepts the value but never passes it to the repetition check, and the agent's standard setup gives that check no limit, so it never refuses a repeated call. goose's tracker has an open issue about how this limit should work, where contributors discuss wiring it up or removing it.
Already tracked upstream (#12150), checked 2026-11-15.
Where:
cli.rs:126-132,services.rs:572,tool_monitor.rs:59-63. How we checked: the code was re-read at the source version named above; the sentences were checked by an independent AI reviewer from another company (OpenAI Codex, read-only) on 2026-11-08, in four rounds; each sentence it questioned was narrowed, removed or kept with the reason recorded. -
2. By default, a failed review check still exits successfully
On goose review's default path, a check or per-file pass that fails, panics or returns output that cannot be parsed adds no findings and prints a warning on stderr. If the review otherwise completes it exits successfully, with nothing on stdout or in the exit status to mark the failed check.
No tracker issue found, checked 2026-11-08.
Where:
orchestrator.rs:124-150,orchestrator.rs:353-389,handler.rs:246-272. How we checked: the code was re-read at the source version named above; the sentences were checked by an independent AI reviewer from another company (OpenAI Codex, read-only) on 2026-11-08, in four rounds; each sentence it questioned was narrowed, removed or kept with the reason recorded. -
3. No code reads a verdict on a /goal
After /goal, goose says the agent will verify the goal before finishing. That check is left to the model: when code later clears the goal, it reads no verdict from the reply.
No tracker issue found, checked 2026-11-08.
Where:
ops_retry.rs:120-123,ops_retry.rs:183-201,ops_retry.rs:219-221. How we checked: the code was re-read at the source version named above; the sentences were checked by an independent AI reviewer from another company (OpenAI Codex, read-only) on 2026-11-08, in four rounds; each sentence it questioned was narrowed, removed or kept with the reason recorded.