fix: bug: gardener hangs forever when Claude finishes without writing phase file (#261) (#263)

Fixes #261

## Changes
Fixed gardener hanging forever when Claude skips phase protocol. Three changes: (1) gardener-agent.sh: replaced 999999s timeout with 7200s (2h, matching dev-agent); (2) lib/agent-session.sh: added idle-prompt detection to monitor_phase_loop — if Claude returns to the ❯ prompt for 3 consecutive polls with no phase file written, exits immediately with _MONITOR_LOOP_EXIT=idle_prompt (only fires when phase file is empty, so awaiting_ci/review waits are unaffected); (3) gardener prompt: removed 'no time limit' wording, replaced with explicit phase-write requirement.

Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/disinto/pulls/263
Reviewed-by: Disinto_bot <disinto_bot@noreply.codeberg.org>
This commit is contained in:
johba 2026-03-19 13:47:10 +01:00
parent e024b0de03
commit d5c2c213a3
5 changed files with 58 additions and 13 deletions

View file

@ -222,7 +222,7 @@ fi
# ── Build prompt from formula + dynamic context ────────────────────────────
log "Building gardener prompt from formula"
PROMPT="You are the issue gardener for ${CODEBERG_REPO}. Work through the formula below — there is no time limit, run until PHASE:done.
PROMPT="You are the issue gardener for ${CODEBERG_REPO}. Work through the formula below. You MUST write PHASE:done to '${PHASE_FILE}' when finished — the orchestrator will time you out if you return to the prompt without signalling.
${CONTEXT_SECTION}
## Formula
@ -303,14 +303,23 @@ gardener_phase_callback() {
esac
}
# No idle timeout — gardener runs until PHASE:done or PHASE:failed
monitor_phase_loop "$PHASE_FILE" 999999 "gardener_phase_callback"
monitor_phase_loop "$PHASE_FILE" 7200 "gardener_phase_callback"
FINAL_PHASE=$(read_phase)
log "Final phase: ${FINAL_PHASE:-none}"
if [ "$FINAL_PHASE" != "PHASE:done" ]; then
log "gardener-agent finished without PHASE:done (phase: ${FINAL_PHASE:-none})"
case "${_MONITOR_LOOP_EXIT:-}" in
idle_prompt)
log "gardener-agent: Claude returned to prompt without writing phase signal — no phase file written"
;;
idle_timeout)
log "gardener-agent: timed out after 2h with no phase signal"
;;
*)
log "gardener-agent finished without PHASE:done (phase: ${FINAL_PHASE:-none}, exit: ${_MONITOR_LOOP_EXIT:-})"
;;
esac
exit 0
fi