From 30d8d083c5aa8e5f94c9643b13661b3c2d02e292 Mon Sep 17 00:00:00 2001 From: hexin Date: Fri, 29 May 2026 17:17:31 +0800 Subject: [PATCH] feat(subagent): add stop-on-failure and bounded-effort guidance to general agent intro The general-purpose sub-agent intro tells the agent how to plan, but says nothing about when to *stop*. With less capable models this leads to a failure mode where the agent retries the same failing tool call (e.g. an unreachable or rate-limited external API) over and over until it hits the elapsed/step ceiling, wasting the whole budget and returning nothing useful. Add two short clauses to GENERAL_AGENT_INTRO: - Stop quickly on failure: after the same call fails twice, return partial results with a one-line note instead of looping. - Bounded effort: prefer one focused attempt; if the task can't be completed within a few tool calls, return current findings so the parent can compensate. Prompt-only change; no behavioral code paths touched. --- crates/tui/src/tools/subagent/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/tui/src/tools/subagent/mod.rs b/crates/tui/src/tools/subagent/mod.rs index 357aeec4..cf10a930 100644 --- a/crates/tui/src/tools/subagent/mod.rs +++ b/crates/tui/src/tools/subagent/mod.rs @@ -4988,7 +4988,9 @@ const SUBAGENT_OUTPUT_FORMAT: &str = include_str!("../../prompts/subagent_output const GENERAL_AGENT_INTRO: &str = concat!( "You are a general-purpose sub-agent spawned to handle a specific task autonomously.\n", "Stay inside the assigned scope; put adjacent work under RISKS/BLOCKERS.\n", - "Plan multi-step work with `checklist_write`; add `update_plan` for complex strategy.\n\n" + "Plan multi-step work with `checklist_write`; add `update_plan` for complex strategy.\n", + "**Stop quickly on failure**: if the same tool call fails 2 times in a row, stop retrying and return what you have so far with a one-line note explaining what's missing. Do not loop on impossible queries (e.g. external API unreachable, rate-limited, or returning empty).\n", + "**Bounded effort**: prefer one focused attempt over many speculative retries. If you cannot complete the task with available data within 3-5 tool calls, return your current partial findings — the parent agent can compensate with its own knowledge.\n\n" ); const EXPLORE_AGENT_INTRO: &str = concat!(