Report agent failures as Error from the hook #114

Closed
opened 2026-08-24 22:31:26 +01:00 by naps62-yolo · 0 comments
Collaborator

The milestone built a whole path for ActivityState::Error: the variant (#102), the endpoint that is the only thing allowed to set it (#105), Session::activity_detail to carry the message, and rendering in both sidebars (#112). Nothing sets it. The shipped hook (#106) maps three events and none of them is a failure:

PostToolUse   -> Active
Notification  -> AwaitingInput
Stop          -> AwaitingInput

So today a red card is unreachable, and the detail string it was built to show has no producer.

Decide what an agent failure actually is in Claude Code's hook vocabulary and report it, with a detail naming the failure. Stop carries the turn's outcome, and SessionEnd fires on abnormal termination — read what the payload on stdin actually contains rather than guessing, since the hook currently discards it (cat >/dev/null).

Two things to settle while doing it, both of which belong in docs/SIDEBAR.md once decided: whether a reported Error should outlive the five-minute TTL (a session that failed is still failed after five minutes, but leaving it red forever means a stale card lies), and what clears it — the next successful PostToolUse, or nothing until the session is killed.

Also worth fixing in passing: PostToolUse fires when a tool finishes, so a session running one long tool call reports Active only after it ends. If a pre-tool event exists, use it.

The milestone built a whole path for `ActivityState::Error`: the variant (#102), the endpoint that is the only thing allowed to set it (#105), `Session::activity_detail` to carry the message, and rendering in both sidebars (#112). Nothing sets it. The shipped hook (#106) maps three events and none of them is a failure: ``` PostToolUse -> Active Notification -> AwaitingInput Stop -> AwaitingInput ``` So today a red card is unreachable, and the detail string it was built to show has no producer. Decide what an agent failure actually is in Claude Code's hook vocabulary and report it, with a `detail` naming the failure. `Stop` carries the turn's outcome, and `SessionEnd` fires on abnormal termination — read what the payload on stdin actually contains rather than guessing, since the hook currently discards it (`cat >/dev/null`). Two things to settle while doing it, both of which belong in `docs/SIDEBAR.md` once decided: whether a reported `Error` should outlive the five-minute TTL (a session that failed is still failed after five minutes, but leaving it red forever means a stale card lies), and what clears it — the next successful `PostToolUse`, or nothing until the session is killed. Also worth fixing in passing: `PostToolUse` fires when a tool *finishes*, so a session running one long tool call reports `Active` only after it ends. If a pre-tool event exists, use it.
naps62-yolo added this to the Sidebar cards milestone 2026-08-24 22:31:26 +01:00
naps62-yolo added the area/clidifficulty/mediumtype/feat labels 2026-08-24 22:31:26 +01:00
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: naps62/maestro#114