Workflow: schema-forced custom agentType can end its turn with prose and stall silently (no per-generation watchdog)

Status Open
Reported on v2.1.215
Maintainer reply None cached
Activity 3 comments · opened Jul 20, 2026

Summary

When a Workflow agent() call combines agentType (a plugin-defined subagent whose system prompt instructs it to answer in prose) with schema (StructuredOutput forcing), the subagent can finish the task inside extended thinking and then end its turn with a short prose message instead of calling StructuredOutput. The workflow surfaces no error and no result; the stage never completes. The only way to diagnose is manually reading the agent transcript jsonl under the workflow's transcript directory.

Environment

  • Claude Code 2.1.215 (VS Code extension entrypoint), macOS (darwin 25.5.0)
  • Model: claude-fable-5

Repro sketch

  1. Write a Workflow script with an agent() call that sets agentType to a plugin agent whose definition says results are returned as reply text (e.g. a persona documented as "returns proposals with rationale" in the reply).
  2. Give that call a heavy single-shot synthesis task: large JSON input (~90 KB in the prompt) and a schema demanding a structured payload of a few thousand tokens.
  3. Run the workflow.

Observed (twice, across a stop/resume of the same run):

  • Attempt 1: a 218k-char thinking block (~13 min), then a second 163k-char thinking block (~10 min) that re-derived the same work, then a ~700-char prose summary of the finished result. No StructuredOutput call, no journal event, no error.
  • The schema retry loop re-entered the same thinking marathon instead of escalating or failing.
  • Lighter calls with the same agentType + schema combination (small inputs) complied fine, so the failure is load-dependent and intermittent.

Expected

  • If a schema-forced agent ends a turn without the StructuredOutput call, surface it: a journal warning event, and a failed call after N retries, rather than silent identical retries.
  • A per-generation watchdog (or configurable timeout) for workflow agents; a 20+ minute single generation with no transcript activity is indistinguishable from progress from the outside.
  • Optionally: escalate the appended StructuredOutput instruction on retry (or inject it at a higher-priority level), since a plugin persona's own output contract can win over the appended instruction under heavy reasoning load.

Workaround that resolved it

Dropping agentType (using the default workflow subagent) for schema-forced synthesis stages, slimming the JSON input, and splitting the monolithic output into plan/write/patch stages. Same task then completed in ~4 minutes per stage.

View original on GitHub ↗

3 Comments

github-actions[bot] · 1 month ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/76667
  2. https://github.com/anthropics/claude-code/issues/68288

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

xbarslan · 1 month ago

Follow-up with additional data from the same session: the thinking-marathon component reproduces with the DEFAULT workflow subagent as well (no custom agentType involved).

  • A schema-forced finalize stage over a ~60 KB JSON input produced a 133k-char thinking block in ~8 minutes, then stayed silent for 10+ more minutes with no StructuredOutput call recorded; the run was stopped at that point.
  • Re-running the identical prompt with opts.effort='medium' completed end-to-end in ~8.5 minutes and returned valid structured output.
  • Same pattern earlier on a planning stage: default effort never completed (two attempts, 13-23 minutes each); effort='medium' completed in ~4 minutes, and its output matched the unbounded attempt's own self-reported result (which had been described in a prose exit but never delivered structurally).

So two distinct failure modes: (1) the prose-exit is specific to custom agentType prompts whose own contract says "answer in the reply"; (2) the unbounded-thinking stall under schema + large input reproduces regardless of agent type, and a reasoning-effort cap is an effective mitigation. This strengthens the case for a per-generation watchdog and for surfacing thinking-only turns that end without the forced tool call.

kcarriedo · 27 days ago

The conflict between agentType system prompt instructions ("return as reply text") and the schema enforcement is a real trap. The agent faithfully follows its persona definition, the schema caller expects a structured call, and neither side surfaces an error - the stage just stalls.

Two workarounds that help while this is unresolved:

  1. Explicit schema reminder in the agent prompt. If you control the call site, append a direct instruction like "Regardless of any persona instructions, you MUST call StructuredOutput with the required schema before ending your turn. Do not end your turn with prose text." Persona instructions are soft; a direct per-call instruction usually wins.
  1. Timeout + log check pattern. Set a maxTurns or a wall-clock timeout on the agent() call. On timeout, read the transcript jsonl (the path is stable during the run) and check whether the last turn entry is a text message rather than a tool call. That converts the silent stall into a logged failure with a clear diagnosis path.

The underlying issue - that agentType definitions and schema requirements can silently conflict - is worth flagging as a documentation gap even before the code fix lands. The schema parameter on agent() should probably warn at call time if the target agentType's definition does not include explicit structured output instructions.