What is Declare Task Succeeded?
Declare Task Succeeded is a specialized tool that allows a focused action agent to immediately terminate workflow execution with a success status when specific success conditions are met. In production, this is an explicit opt-in tool: wire it into afocused_action prompt only when you want that focused action to be allowed to end the entire workflow early.
In your prompts, always refer to this tool as
declare_task_succeeded (lowercase, with underscores).Think of
declare_task_succeeded as an early-exit switch that you intentionally wire into a focused action prompt, not as a general “the agent can decide to stop whenever it thinks the task is done” behavior.Why This Tool Exists
During cached workflow replay, the main agent is not invoked—actions are replayed deterministically from the trajectory. However,focused_action always runs dynamically, even during cached runs. This creates situations where:
- A focused action discovers the task is already complete (e.g., data was already processed)
- A user-defined success condition is met earlier than expected
- The focused action determines no further steps are needed
declare_task_succeeded, the focused action would return to the trajectory replay, which would continue executing remaining steps unnecessarily.
How It Works
- A focused action evaluates the current screen state
- Your prompt tells that focused action exactly when it should call
declare_task_succeeded - If that success condition is met, it calls
declare_task_succeeded(optionally with a description of why) - Workflow execution immediately terminates with success status
- Trajectories are committed (the successful path is saved)
- Normal success cleanup occurs (status update, webhooks, etc.)
The
text parameter is optional. If omitted, a default “Task completed successfully” message is used.Unlike
declare_task_failed which clears pending trajectories, declare_task_succeeded commits them because the workflow reached a valid success state.When to Use Declare Task Succeeded
1. Early Success Detection
When a focused action discovers the goal is already achieved and your prompt explicitly allows early success:2. Conditional Workflow Completion
When success depends on dynamic content evaluation and you want the focused action to end the run immediately:3. Goal-Based Termination
When the focused action can determine the workflow’s goal is met and you have explicitly granted it permission to stop the run:How to Prompt for Task Success
Best Practices
- Be Specific: Clearly define what constitutes success
- Explain the Condition: Describe what the focused action should look for
- Write the Exact Tool Name: Include the literal phrase
declare_task_succeededin the prompt when you want to enable this behavior - Include Context: Specify what message to include when succeeding
- Use in Focused Actions: Remember this is only for dynamic success detection
Prompt Template
Real-World Examples
Healthcare: Record Already Updated
Finance: Transaction Already Processed
E-commerce: Order Already Fulfilled
IT Operations: System Already Configured
Comparison: declare_task_succeeded vs declare_task_failed
| Aspect | declare_task_succeeded | declare_task_failed |
|---|---|---|
| Purpose | Signal successful completion | Signal unrecoverable failure |
| Trajectory | Committed (saved) | Cleared (not saved) |
| Run Status | SUCCESS | ERROR |
| Use Case | Goal achieved early | Insurmountable obstacle |
| Availability | Focused action only, and only when explicitly instructed in the prompt | All agents |
Integration with Cached Workflows
This tool is particularly valuable in cached workflows where you want a dynamically evaluatedfocused_action check to have permission to end the run:
Common Patterns
Pre-flight Success Check
Polling with Success Detection
Idempotent Operations
Common Mistakes to Avoid
Incorrect Usage
Correct Usage
Best Practices Summary
- Use only within focused_action - This is the key constraint
- Explicitly include
declare_task_succeededin the instructions - The focused action should not infer this behavior on its own - Define clear success conditions - Be specific about what “success” means
- Consider adding descriptive messages - Optionally explain why the workflow succeeded (helps debugging)
- Consider idempotency - Great for workflows that should be safe to re-run
- Pair with declare_task_failed - Handle both success and failure conditions
- Think about cached replay - Most valuable when focused actions run during trajectory replay