Problem
When executing tasks, the agent fails ungracefully in two common scenarios:
1. File Conflicts (file_create on existing files)
When a task is re-executed (e.g., after a previous failed run), the agent's plan still uses file_create for files that already exist from the previous attempt. This causes immediate step failures:
Step 1: src/task_tracker/exceptions.py → Failed: File already exists
Step 2: src/task_tracker/validators.py → Failed: File already exists
Expected behavior: The agent should detect existing files and fall back to file_edit or file_overwrite, or the planner should check for existing files before choosing the operation.
2. Cascading Verification Failures
After each file change, the agent runs incremental verification (ruff). When verification fails, the agent marks the step as failed and moves on, but downstream steps that depend on the failed file also fail:
Step 3: src/task_tracker/storage.py → stdout → Failed: Code verification failed
Step 4: src/task_tracker/commands/add.py → stdout → Failed: Code verification failed
Step 5: src/task_tracker/commands/delete.py → stdout → Failed: Code verification failed
... (all remaining steps fail)
This wastes significant time and API tokens — in the observed case, 893 seconds of execution with 20 steps all failing.
Expected behavior: The agent should either:
- Fix verification errors inline before proceeding (self-correction loop exists but doesn't trigger for incremental verification)
- Abort early after N consecutive failures instead of continuing through all 20 steps
- Re-plan remaining steps accounting for the verification failures
Proposed Improvements
File Conflict Handling
Verification Recovery
Observability
Context
Observed during cf-test workspace execution where all 12 tasks failed. 10 tasks had file_create conflicts from previous runs, and verification failures cascaded through all remaining steps.
Related
- Agent self-correction loop:
core/agent.py _run_final_verification() / _attempt_verification_fix()
- Executor file operations:
core/executor.py
- Verification gates:
core/gates.py
Problem
When executing tasks, the agent fails ungracefully in two common scenarios:
1. File Conflicts (file_create on existing files)
When a task is re-executed (e.g., after a previous failed run), the agent's plan still uses
file_createfor files that already exist from the previous attempt. This causes immediate step failures:Expected behavior: The agent should detect existing files and fall back to
file_editorfile_overwrite, or the planner should check for existing files before choosing the operation.2. Cascading Verification Failures
After each file change, the agent runs incremental verification (ruff). When verification fails, the agent marks the step as failed and moves on, but downstream steps that depend on the failed file also fail:
This wastes significant time and API tokens — in the observed case, 893 seconds of execution with 20 steps all failing.
Expected behavior: The agent should either:
Proposed Improvements
File Conflict Handling
executor.pyfile_create: if file exists, fall back to overwrite (orfile_editif content differs)planner.py: scan workspace for existing files before generating the plan, preferfile_editwhen target existscf work clean <task-id>) to remove artifacts from failed runsVerification Recovery
Observability
Context
Observed during cf-test workspace execution where all 12 tasks failed. 10 tasks had
file_createconflicts from previous runs, and verification failures cascaded through all remaining steps.Related
core/agent.py_run_final_verification()/_attempt_verification_fix()core/executor.pycore/gates.py