Files
coyote/assets/agents/step-runner/scripts/note_llm_fault.sh
T
Dark-Alex-17 22976a79f9 fix(TASK-020): surface step-runner LLM-fault captures where the fallback lands
The three fallback-capture keys (orient_failure, sweep_failure,
handoff_failure) were write-only dead state: captured on LLM-node failure
but interpolated nowhere, so end_failure rendered an empty STEP_FAILED
shell and write_handoff carried no trace a dead sweep.

- new crash-proof script node note_llm_fault distills orient/handoff
  'LLM node...' failure text into fault_note (prefix-anchored; empty when
  neither key holds a fault); orient and write_handoff fallbacks now route
  through it before end_failure
- end_failure renders 'Pipeline fault (if any): {{fault_note}}' (sentinel
  and all existing fields preserved; fault_note defaulted in initial_state)
- write_handoff prompt interpolates {{sweep_failure}} with a
  PIPELINE-FAULT VISIBILITY instruction mirroring the review_report
  treatment (fault -> Deviations entry + step_summary; success/empty
  ignored)
- tests: note_llm_fault fault/clean/crash/truncation paths via the
  GRAPH_STATE harness; wiring test pins the retargeted fallbacks,
  note_llm_fault routing, {{fault_note}} in end_failure, and the
  sweep-fault prompt/instruction anchors; warning baseline unchanged
2026-09-14 10:50:33 -06:00

27 lines
843 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${GRAPH_STATE_FILE:-}" ]]; then
state=$(cat "$GRAPH_STATE_FILE")
elif [[ -n "${GRAPH_STATE:-}" ]]; then
state="$GRAPH_STATE"
else
state='{}'
fi
orient_failure=$(echo "$state" | jq -r '.orient_failure // ""')
handoff_failure=$(echo "$state" | jq -r '.handoff_failure // ""')
# Engine failure text is always prefix-anchored "LLM node" (llm.rs); on
# success these keys hold the node's structured JSON output, which never
# starts with that prefix.
if [[ "$orient_failure" == "LLM node"* ]]; then
fault_note="PIPELINE-FAULT: orient stage failed — ${orient_failure:0:300}"
elif [[ "$handoff_failure" == "LLM node"* ]]; then
fault_note="PIPELINE-FAULT: handoff stage failed — ${handoff_failure:0:300}"
else
fault_note=""
fi
jq -nc --arg note "$fault_note" '{"fault_note": $note}'