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.
This commit is contained in:
hexin
2026-05-29 17:17:31 +08:00
committed by Hunter Bown
parent c72dc28b38
commit 30d8d083c5
+3 -1
View File
@@ -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!(