mirror of
https://github.com/lukaszraczylo/claude-adam.git
synced 2026-10-19 06:17:45 +00:00
feat(observe): record real tool failures from PostToolUseFailure
Claude Code sends failed tool calls to the PostToolUseFailure event. ADAM registered only PostToolUse, so it never saw a real failure, and every tool_error_loop came from ERROR_RE matching successful output. Handle PostToolUseFailure in adam-observe.mjs through the PostToolUse detectors. Shape the error string as an is_error response. An interrupt is an abort, so it counts as a tool event but gets no fingerprint. Register the event in settings.json.example. Tests 9b and 9c added: 150 passed, 0 failed. Claude-Session: https://claude.ai/code/session_014prTNuJnKuwcAd28vUZAnN
This commit is contained in:
@@ -187,6 +187,25 @@ for i in 1 2 3; do
|
||||
done
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"tool_error_loop"' "3x same error logs tool_error_loop"
|
||||
|
||||
# --- Test 9b: PostToolUseFailure feeds the same detectors ---
|
||||
echo "Test 9b: 3x PostToolUseFailure with the same error logs tool_error_loop"
|
||||
reset_state
|
||||
for i in 1 2 3; do
|
||||
echo '{"hook_event_name":"PostToolUseFailure","tool_name":"Bash","tool_input":{"command":"npm test"},"error":"Exit code 1\nError: Cannot find module express","is_interrupt":false,"session_id":"s9b","cwd":"/tmp/x"}' \
|
||||
| HOOK_RUN >/dev/null 2>&1 || true
|
||||
done
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"tool_error_loop"' "3x PostToolUseFailure logs tool_error_loop"
|
||||
|
||||
# --- Test 9c: interrupted tool calls are not errors ---
|
||||
echo "Test 9c: 8x PostToolUseFailure with is_interrupt:true counts as tool use but logs no tool_error_loop"
|
||||
reset_state
|
||||
for i in 1 2 3 4 5 6 7 8; do
|
||||
echo '{"hook_event_name":"PostToolUseFailure","tool_name":"Bash","tool_input":{"command":"sleep 99"},"error":"Error: aborted","is_interrupt":true,"session_id":"s9c","cwd":"/tmp/x"}' \
|
||||
| HOOK_RUN >/dev/null 2>&1 || true
|
||||
done
|
||||
assert_grep "$ROOT/journal.jsonl" '"type":"dead_end"' "interrupted calls still count as tool events"
|
||||
assert_no_grep "$ROOT/journal.jsonl" '"type":"tool_error_loop"' "interrupts do not log tool_error_loop"
|
||||
|
||||
# --- Test 10: dead_end on long autonomous run ---
|
||||
echo "Test 10: dead_end after 8 tools without UserPromptSubmit"
|
||||
reset_state
|
||||
|
||||
Reference in New Issue
Block a user