Repository navigation
Description
Problem
When running the /goal command through agent-canvas against the software-agent-sdk, the goal loop frequently stops mid-way with an interrupted status, requiring a manual click of the "resume" button to continue. This defeats the purpose of the goal command, which is supposed to keep working until the objective is finished.
Reproduction looks like:
Goal: …
Round 4/10
interrupted
Root cause
The goal loop in EventService._run_goal_loop (openhands-agent-server/openhands/agent_server/event_service.py) treats a STUCK run the same as PAUSED/ERROR — all three cause a hard terminal stop that emits interrupted and halts the loop:
status = await self._get_execution_status()
if status in (
ConversationExecutionStatus.PAUSED,
ConversationExecutionStatus.ERROR,
ConversationExecutionStatus.STUCK, # <-- problem
):
logger.info("Goal loop halted early: status=%s", status)
await _emit_status(active=False, status="interrupted")
returnThe STUCK status comes from the StuckDetector (openhands/sdk/conversation/stuck_detector.py), a heuristic that fires on repetitive action/observation patterns. Its default thresholds are aggressive (action_observation=4, action_error=3, monologue=3). These thresholds were tuned for single-turn chat, but during a goal loop the agent intentionally iterates — re-running a test, retrying an edit, re-reading a file — so it's easy to trip one of these thresholds during legitimate work, ending the run as STUCK and halting the whole goal.
Why this is wrong
The goal loop already has an authoritative judge LLM (GoalController + judge_goal) that audits the transcript each round and decides continue-vs-stop with concrete completion evidence. That judge is a far better progress signal than the stuck detector's repetition heuristic. Layering the stuck detector's hard halt on top of the judge defeats the "keep working until finished" contract.
The three terminal statuses are conflated despite meaning very different things:
PAUSED— deliberate user stop → correctly halts the goal (interrupted, resumable)ERROR— real failure (e.g. out of credits) → correctly halts the goal (interrupted, resumable)STUCK— heuristic guess, often a false positive during legitimate iteration → should NOT halt the goal
Suggested fix
In _run_goal_loop, remove STUCK from the set of statuses that terminate the goal. Only PAUSED and ERROR (real stop signals) should halt. A STUCK run should proceed to the judge path, which either marks the goal complete or sends a followup nudge (FOLLOWUP_PROMPT) that breaks the agent out of any genuine loop. Worst case the goal caps out at max_iterations (bounded), which is strictly better than halting early at round 4.
The fix is implemented in the linked PR.
This issue was created by an AI agent (OpenHands) on behalf of a user.
Activity