[Feature] Allow workflow scripts to mark agent results as failed (red indicator)

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 28, 2026

Problem

When using the Workflow tool with agent(), the left-panel status indicators only show red (✗) when an agent experiences a runtime error (stall timeout, API error, user skip, StructuredOutput retry cap exceeded). There is no mechanism to mark an agent as failed based on its logical outcome.

Use Case

I have a deployment/regression workflow that:

  1. Triggers a CI pipeline
  2. Polls for completion
  3. Returns the result (PASSED/FAILED)

When the regression fails, the agent completes successfully (green ✔) because it ran without runtime errors — even though the business outcome is a failure. The workflow then throws to stop execution, which marks the overall workflow as failed, but the individual agent still shows green.

What I've Tried

  • exit 1 in bash — agent handles it gracefully, still returns text
  • Schema tricks — agent reads the schema and always conforms
  • throw new Error() — only affects the workflow level, not the agent that already completed
  • Intentionally calling non-existent tools — agent catches gracefully
  • Setting MAX_STRUCTURED_OUTPUT_RETRIES=1 with impossible schemas — unreliable since model reads the schema

Proposed Solutions (any of these would work)

  1. agent(prompt, { failIf: (result) => boolean }) — callback that, if returns true, marks the agent as error state in the UI
  2. agent(prompt, { assertSuccess: true }) combined with the agent calling a ReportFailure tool — explicit opt-in failure reporting
  3. Allow throw inside agent() to propagate as agent error — if the agent itself throws (via a mechanism like calling a special tool), show red
  4. Post-hoc marking: markFailed(agentResult) function in workflow scripts that retroactively changes the progress indicator

Expected Behavior

When a workflow agent produces a result that the script determines is a failure, the /workflows left panel should show a red ✗ for that specific agent — not just for the overall workflow.

Environment

  • Claude Code CLI (latest)
  • macOS
  • Using named workflows (.claude/workflows/)

View original on GitHub ↗