From aa89e2b31e37c7ad119995244ec774ee2ee1ce38 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 20 Mar 2026 23:35:34 +0000 Subject: [PATCH] fix: move write_compact_context after create_agent_session in gardener-agent The context file was written before the reset block that deleted it, making compaction re-injection a no-op for gardener sessions. Co-Authored-By: Claude Opus 4.6 (1M context) --- gardener/gardener-agent.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gardener/gardener-agent.sh b/gardener/gardener-agent.sh index d4cb1ac..868076d 100644 --- a/gardener/gardener-agent.sh +++ b/gardener/gardener-agent.sh @@ -267,13 +267,6 @@ When all work is done and verify confirms zero tech-debt: On unrecoverable error: printf 'PHASE:failed\nReason: %s\n' 'describe error' > '${PHASE_FILE}'" -# Write phase protocol to context file for compaction survival -write_compact_context "$PHASE_FILE" "## Phase protocol (REQUIRED) -When all work is done and verify confirms zero tech-debt: - echo 'PHASE:done' > '${PHASE_FILE}' -On unrecoverable error: - printf 'PHASE:failed\nReason: %s\n' 'describe error' > '${PHASE_FILE}'" - # ── Reset phase + result files ──────────────────────────────────────────── agent_kill_session "$SESSION_NAME" rm -f "$PHASE_FILE" "${PHASE_FILE%.phase}.context" "$RESULT_FILE" @@ -286,6 +279,13 @@ if ! create_agent_session "$SESSION_NAME" "$PROJECT_REPO_ROOT" "$PHASE_FILE"; th exit 1 fi +# Write phase protocol to context file for compaction survival +write_compact_context "$PHASE_FILE" "## Phase protocol (REQUIRED) +When all work is done and verify confirms zero tech-debt: + echo 'PHASE:done' > '${PHASE_FILE}' +On unrecoverable error: + printf 'PHASE:failed\nReason: %s\n' 'describe error' > '${PHASE_FILE}'" + agent_inject_into_session "$SESSION_NAME" "$PROMPT" log "Prompt sent to tmux session" matrix_send "gardener" "🌱 Gardener session started for ${CODEBERG_REPO}" 2>/dev/null || true