Declare Task Failed is a specialized tool that allows your agent to immediately terminate workflow execution when specific failure conditions are met. This prevents the agent from continuing to attempt a task that cannot be completed, saving time and resources.
In your prompts, always refer to this tool as declare_task_failed (lowercase, with underscores).
The agent encounters a condition you’ve defined as a failure
It calls declare_task_failed with a description of the failure
Workflow execution immediately terminates
The run is marked as failed
No trajectory is saved (the run is not cached)
The failure reason is recorded for debugging
Important: Once declare_task_failed is called, the workflow stops immediately. This tool is never cached because failed runs don’t create trajectories.
"If you see 'Account Locked' or 'Invalid Credentials' after attempting login, use declare_task_failed to terminate the workflow. Do not attempt password recovery or multiple login attempts."
"Search for patient ID {patient_id}. If no results are found after searching, use declare_task_failed indicating 'Patient ID {patient_id} not found in system'. Do not proceed with empty data."
"If the application shows 'System Maintenance in Progress' or fails to load after 30 seconds, use declare_task_failed stating 'Target system unavailable'."
"Check the account balance before processing. If balance is less than {required_amount}, use declare_task_failed with message 'Insufficient funds: balance below required amount'."
"When searching for the patient's medication list, if you see any alert about 'Drug Interaction Warning - Contraindicated', immediately use declare_task_failed with message 'Critical drug interaction detected - manual review required'. Do not proceed with the prescription."
"Before initiating the transfer, verify the recipient is not on the sanctions list. If the screen shows 'Compliance Alert - Restricted Entity', use declare_task_failed stating 'Transfer blocked - recipient on sanctions list'. Do not attempt workarounds."
"Check inventory for all items in order {order_id}. If any item shows 'Out of Stock' or 'Discontinued', use declare_task_failed with message 'Order cannot be fulfilled - {item_name} unavailable'. Do not process partial orders."
"Before deploying, check the pre-deployment tests. If status shows 'FAILED' for any critical test, use declare_task_failed with 'Deployment aborted - critical test failures detected'. Do not override or skip failed tests."
"Attempt to connect to the database. If connection fails, retry up to 3 times with 10-second intervals. If still failing after 3 attempts, use declare_task_failed with 'Database connection failed after 3 attempts'."
"Click 'Generate Report' and wait for completion. If the progress bar doesn't finish within 5 minutes, use declare_task_failed stating 'Report generation timeout - exceeded 5 minute limit'."
"After filling the form, click Submit. If validation errors appear for required fields that cannot be populated from the provided data {input_data}, use declare_task_failed listing the missing required fields."
"Navigate to the admin panel. If you see 'Access Denied' or 'Insufficient Privileges', use declare_task_failed with 'User lacks required admin permissions'. Do not attempt to access via other routes."
"If login fails with 'Account Locked', use declare_task_failed""If the file is corrupted (shows 'Cannot read file'), use declare_task_failed""If payment is declined with 'Card Reported Stolen', use declare_task_failed"
"The workflow requires sequential approvals from 3 departments. If any department shows 'Request Denied' or 'Not Authorized', use declare_task_failed immediately with 'Approval chain broken at {department_name}'. Don't continue to other departments."
"Use focused_action to check if an error message appears after submission. If the error contains 'Fatal', 'Critical', or 'Unrecoverable', use declare_task_failed with the full error message."
"Use execute_terminal_command to run 'Test-Path C:\RequiredFiles\config.xml'. If it returns False, use declare_task_failed with 'Required configuration file missing'."
"Check the order status. If status is 'Cancelled' or 'Refunded', use declare_task_failed with 'Order {order_id} already {status} - no action needed'. Only proceed if status is 'Pending' or 'Processing'."
"Monitor the batch processing progress. Use declare_task_failed if:1. More than 10% of items fail processing2. Any critical error (severity = 'CRITICAL') appears in logs3. Processing time exceeds 30 minutes4. System memory usage exceeds 90%Include specific failure reason in the message."
"Process all invoices in the list. Keep track of successes and failures. If more than 50% fail, use declare_task_failed with 'Batch processing failed - {failed_count} of {total_count} invoices failed'. Otherwise, complete successfully even with some failures."
"Before starting the main workflow:1. Verify all required applications are running2. Check available disk space > 10GB3. Confirm network connectivity to required servicesIf any check fails, use declare_task_failed with specific check that failed. This prevents wasting time on doomed workflows."
"If the page takes more than 2 seconds to load, use declare_task_failed" // Too aggressive"If anything goes wrong, use declare_task_failed" // Too vague"After completing successfully, use declare_task_failed" // Wrong tool
"If login fails with 'Account Suspended', use declare_task_failed""If required file is missing after checking 3 locations, use declare_task_failed""If the API returns 403 Forbidden, use declare_task_failed with 'API access denied'"