> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ada.cx/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ada.cx/_mcp/server.

# Code tools: let a Playbook recover when a tool fails

A Code tool can now report how its run ended. A Playbook can branch on that outcome instead of handing the conversation to a human agent. Before this change, a failed run exited the Playbook and forced a handoff. A run fails when the code raises an error, exceeds a limit, or receives an input of the wrong type.

## What's new

The **Outputs** section of a Code tool now offers an output that reports how the run ended.

* **Add the status output.** Enable **Let playbooks branch when this tool fails** in the Code tool's **Outputs** section. Ada adds an output named `ada_run_status`. The name is fixed, and the **Path** field does not apply.
* **Branch on the status.** Save the output to a variable. Read that variable from an `IF/ELSE` step after the `RUN` step. When a condition references the variable, the automatic handoff stops and your branches own the fallback. Retry the tool, send a message, or hand off.
* **Five status values.** The status is `ok`, `timeout`, `error`, `invalid_input` or `disabled`. A `timeout` is the clearest case for a retry.
* **Only the run status has a value after a failure.** Every other output selects part of the value the code returned. A failed run returns nothing, so those outputs hold no value.

Learn more about [the run status output](/docs/automation/tools/code-tools/inputs-outputs-and-environment#let-playbooks-branch-when-the-tool-fails) and [Code tool error handling in a Playbook](/docs/automation/playbooks/step-reference#code-tool-error-handling).