A jevhook

Tell the assistant why a tool call failed

When a tool call fails, the assistant often guesses wrong about why: it runs the same command again, or edits your code to get round a program that is not installed. This check sorts each failure into one of six kinds (a missing program, a fault that may clear on a second try, the machine’s setup, a refused permission, the tool called wrongly, a real defect in the work) and puts one line beside the error saying what to do next. After “cargo-nextest: command not found”, the line says to check what is installed before trying again. The third time the same failure comes back, the assistant is told not to send that call again.

It starts in shadow: it writes down what it would have done and changes nothing, until you switch it on. It acts at PostToolUseFailure.

Jev is the small, fast model jevhooks asks. It writes nothing: it is handed a question whose answers are already written down, and says how likely each one is, in about a quarter of a second. jevhooks is a plugin for Claude Code that asks it at the moments Claude Code lets a plugin step in, and a jevhook is one such question with what is done about the answer.

Exactly what it does

  • Jev is asked which of six kinds of failure this is: a missing dependency, a passing fault (one that may clear on a second try), the machine's setup, a refusal of permission, the tool called wrongly, or a real defect in the work.
  • When Jev is at least 60% sure of one kind, the assistant reads one line beside the error: which kind it is and what to do about it.
  • From the 3rd time the same tool fails the same way in a session, the assistant is told not to send the same call again; jevhooks counts this itself and does not ask Jev.
  • The assistant is told about at most 5 failures in a session; after that this check stays quiet and Jev is not asked.
  • Nothing is refused.

Its switch

  • At PostToolUseFailure it is PostToolUseFailure/failurestarts in shadow
    Say something

A jevhook is off, in shadow or on. To change this one, put this in ~/.config/jevhooks/config.toml:

[jevhooks.PostToolUseFailure]
failure = "on"

In shadow Jev is asked and nothing is changed. The log (jevhooks recent, or /jev in a session) then says what would have been done: for this one, what the assistant would have been told.

4 worked cases, each an answer Jev could give, the rules that decide on it, and the screen you would see. The ones you would meet most come first, and the 2 at the edges last: a switch that is off, a cap that is spent, an answer Jev is not sure of.

A call that failed, before the assistant reads the failure

The rules these cases run through

7 rules decide what the assistant is told about a failed call, from 4 things known, 1 of them Jev's answers: which of 6 kinds of failure this is, told at 60%. The plugin counts how often the same failure has happened, and from the 3rd time says so, with Jev or without. Both can be told at once, in one line. A session is told about 5 failures and then left alone. Nothing is refused.

sh: cargo-nextest: command not found missing-dependency

Jev is 90% sure a program is missing. The assistant reads one line beside the failure: check what is installed, and if something has to be installed, say which and why.

Jev, in one requestfailureonfailure: toldnothe same againnokind90%= yes= no= yes= missing-dependency= transient= environment= permission= wrong-usage= real-bug&&&&&&&&the same failure again → say soa missing dependency → say which1a passing fault → say whichthe machine's setup → say whichpermission refused → say whichthe tool called wrongly → say whicha real defect → say which

Open this drawing at its own size

How to read a drawing

Jev answers with numbers. What happens next is decided by a few rules, in order: of the rules that hold, the first decides. They are compiled into one small network, and these pictures are drawn from that network, not beside it, so they cannot show a rule the plugin does not have.

Read one left to right: what can be known, the tests on it, where a rule's tests meet, and the rules. Black is what a rule that holds stands on, and dashed is a test that failed. A pink rule holds; more than one can, and the numbered ones are those that decided, in order. The framed facts are Jev's, and are asked for together, in one request.

❯ run the tests

● Bash(cargo nextest run)
  ⎿  Error: sh: cargo-nextest: command not found

✻ Working…
result: Jev: a missing dependency (90%) · 150 ms · $0.0002 this session                                              [-]

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ manual mode on · esc to interrupt

The assistant reads beside the failure:

jevhooks: This failure looks like a missing dependency (Jev: 90%). Check what is installed before trying again; if something has to be installed, say which and why.
the same type error, for the third time again + real-bug

jevhooks has counted this failure three times this session, without asking Jev, and Jev is 95% sure it is a real defect in the work. The assistant is told both in one line: do not send the same call again, and fix the cause.

Jev, in one requestfailureonfailure: toldnothe same againyeskind95%= yes= no= yes= missing-dependency= transient= environment= permission= wrong-usage= real-bug&&&&&&&&the same failure again → say so1a missing dependency → say whicha passing fault → say whichthe machine's setup → say whichpermission refused → say whichthe tool called wrongly → say whicha real defect → say which2

Open this drawing at its own size

❯ make the importer return the rows it skipped

● Bash(cargo check)
  ⎿  Error: error[E0308]: mismatched types: expected `Vec<Row>`, found `usize` (src/importer.rs:84)

✻ Working…
result: Jev: the same failure, 3 times now; a real defect in the work (95%) · 150 ms · $0.0002 this session          [-]

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ manual mode on · esc to interrupt

The assistant reads beside the failure:

jevhooks: Bash has failed this same way 3 times this session. Do not send the same call again unchanged: take another approach, or tell the user what is in the way. This failure looks like a real defect in the work (Jev: 95%). Read the error and fix its cause, not the check that reported it.
an error Jev cannot place nothing told

Jev says 45% a real defect and 40% the tool called wrongly. Neither reaches 60%, and the two are not added together, so the assistant is told nothing.

Jev, in one requestfailureonfailure: toldnothe same againnokind45%= yes= no= yes= missing-dependency= transient= environment= permission= wrong-usage= real-bug&&&&&&&&the same failure again → say soa missing dependency → say whicha passing fault → say whichthe machine's setup → say whichpermission refused → say whichthe tool called wrongly → say whicha real defect → say which

Open this drawing at its own size

❯ run the importer's own tests

● Bash(cargo test --test importer)
  ⎿  Error: error: no test target named `importer`

✻ Working…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ manual mode on · esc to interrupt
a sixth failure, after the session has been told about five Jev is not asked

The assistant has already been told about five failures this session. That is the cap, so Jev is not asked and nothing is added beside the error.

Jev, in one requestfailureonfailure: toldyesthe same againyeskind= yes= no= yes= missing-dependency= transient= environment= permission= wrong-usage= real-bug&&&&&&&&the same failure again → say soa missing dependency → say whicha passing fault → say whichthe machine's setup → say whichpermission refused → say whichthe tool called wrongly → say whicha real defect → say which

Open this drawing at its own size

❯ get the build green

● Bash(cargo build)
  ⎿  Error: error[E0425]: cannot find function `parse_row` in this scope (src/importer.rs:31)

✻ Working…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ manual mode on · esc to interrupt

What this site keeps about a visit, and how to refuse it, is said in one place: what is kept.