Summary
Wire the stall detector into the ReAct agent's tool-use loop and the runtime's task execution flow.
Parent issue: #399
Scope
Changes to core/react_agent.py
- Initialize
StallDetector at the start of ReactAgent.run()
- Call
stall_detector.record_activity() after each successful tool execution
- Check
stall_detector.is_stalled() at the top of each iteration loop
- On stall detection:
- Log warning with elapsed time and last tool call context
- Based on configured
StallAction:
RETRY: raise StallDetectedError (runtime handles retry)
BLOCKER: create blocker with stall context, return BLOCKED
FAIL: return FAILED with stall reason
Changes to core/runtime.py
- Catch
StallDetectedError in execute_agent()
- If retry configured: re-invoke agent (respecting max retry count)
- If blocker configured: create blocker with diagnostic context:
- Time since last activity
- Last tool call and result
- Current iteration count
- Token usage so far
Changes to CLI
- Add
--stall-timeout flag to cf work start (default: 300s, 0 to disable)
- Pass through to runtime/agent
Acceptance Criteria
Dependencies
Summary
Wire the stall detector into the ReAct agent's tool-use loop and the runtime's task execution flow.
Parent issue: #399
Scope
Changes to
core/react_agent.pyStallDetectorat the start ofReactAgent.run()stall_detector.record_activity()after each successful tool executionstall_detector.is_stalled()at the top of each iteration loopStallAction:RETRY: raiseStallDetectedError(runtime handles retry)BLOCKER: create blocker with stall context, return BLOCKEDFAIL: return FAILED with stall reasonChanges to
core/runtime.pyStallDetectedErrorinexecute_agent()Changes to CLI
--stall-timeoutflag tocf work start(default: 300s, 0 to disable)Acceptance Criteria
--stall-timeout 120sets custom timeout via CLI--stall-timeout 0disables stall detectionDependencies