Built-in deep-research workflow: Scope phase exhausts StructuredOutput retry cap on long briefs
What happened
The built-in deep-research workflow (run via the /deep-research skill or Workflow({name:'deep-research', args})) dies in its first phase ("Scope") when args is a long brief.
With a brief of ~4,000 words (also reproducible at ~2.5k characters), the Scope agent fails repeatedly and the run aborts with:
agent({schema}): StructuredOutput retry cap (5) exceeded
The workflow never reaches Search/Fetch/Verify/Synthesize.
Root cause
The Scope phase injects the entire question into the agent prompt and SCOPE_SCHEMA requires returning it back:
const SCOPE_SCHEMA = {
type: "object", required: ["question", "angles", "summary"],
properties: { question: { type: "string" }, /* ... */ },
}
// prompt:
"Return: the question (verbatim or lightly normalized), a 1-2 sentence decomposition strategy, and the angles."
Forcing the model to re-emit thousands of characters (with quotes, newlines and URLs) inside the StructuredOutput tool call fails over and over until the retry cap is hit.
Notably, the question field is never consumed downstream — the rest of the script uses its own QUESTION variable (the full args), not scope.question. So the required question field is dead weight that only creates a failure mode.
Suggested fix (Scope phase only)
- Drop
questionfromSCOPE_SCHEMA.required(keep it optional, or remove it). - Truncate what gets injected into the Scope prompt (e.g. first ~1,500 chars + a "[truncated]" note) and keep the full text in the workflow variable for the later phases.
- Ask the Scope agent for a short summary instead of a verbatim echo.
Short questions are unaffected (truncation is a no-op). Verified working by forking the workflow with exactly these three changes: a 2,582-char brief produces 5 clean angles in a single agent call, no retry-cap exhaustion.
Environment
- Claude Code 2.1.173 (native install, macOS arm64)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗