From 59b4cafcfc43138f09dfb3005fc02cbb3ae42ce2 Mon Sep 17 00:00:00 2001 From: johba Date: Sat, 28 Mar 2026 23:03:17 +0000 Subject: [PATCH] fix: log Claude output diagnostics on no_push failure Save agent_run output to agent-run-last.json. On no_push, log the result text, turn count, and cost. Save full output to no-push-{issue}-{ts}.json for later analysis. Co-Authored-By: Claude Opus 4.6 (1M context) --- dev/dev-agent.sh | 12 ++++++++++++ lib/agent-sdk.sh | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/dev/dev-agent.sh b/dev/dev-agent.sh index bdbdb70..21b913e 100755 --- a/dev/dev-agent.sh +++ b/dev/dev-agent.sh @@ -454,6 +454,18 @@ Closing as already implemented." fi log "ERROR: no branch pushed after agent_run" + # Dump diagnostics + local diag_file="${DISINTO_LOG_DIR:-/tmp}/dev/agent-run-last.json" + if [ -f "$diag_file" ]; then + local result_text cost_usd num_turns + result_text=$(jq -r '.result // "no result field"' "$diag_file" 2>/dev/null | head -50) || result_text="(parse error)" + cost_usd=$(jq -r '.cost_usd // "?"' "$diag_file" 2>/dev/null) || cost_usd="?" + num_turns=$(jq -r '.num_turns // "?"' "$diag_file" 2>/dev/null) || num_turns="?" + log "no_push diagnostics: turns=${num_turns} cost=${cost_usd}" + log "no_push result: ${result_text}" + # Save full output for later analysis + cp "$diag_file" "${DISINTO_LOG_DIR:-/tmp}/dev/no-push-${ISSUE}-$(date +%s).json" 2>/dev/null || true + fi issue_block "$ISSUE" "no_push" "Claude did not push branch ${BRANCH}" CLAIMED=false worktree_cleanup "$WORKTREE" diff --git a/lib/agent-sdk.sh b/lib/agent-sdk.sh index 41879bf..0fe6539 100644 --- a/lib/agent-sdk.sh +++ b/lib/agent-sdk.sh @@ -58,4 +58,9 @@ agent_run() { printf '%s' "$new_sid" > "$SID_FILE" log "agent_run: session_id=${new_sid:0:12}..." fi + + # Save output for diagnostics (no_push, crashes) + _AGENT_LAST_OUTPUT="$output" + local diag_file="${DISINTO_LOG_DIR:-/tmp}/dev/agent-run-last.json" + printf '%s' "$output" > "$diag_file" 2>/dev/null || true }