Urgent.News

What's breaking now, across thousands of outlets.

Tech

"A Crashed PreToolUse Hook Leaves No Trace in the Model's Context; Telling It to Block Leaves Too Much"

Two readers left comments on yesterday's piece about Claude Code's PreToolUse hook exit codes that I couldn't answer honestly at the time. One asked what happens to stderr output from a crashing hook — does it leak into the model's context, or just disappear. The other asked about an onFailure: "block" setting I hadn't tested. Yesterday's article only established that a non-2 exit code lets the…

Two readers commented on last week's article about Claude Code's PreToolUse hook exit codes, asking about what happens to stderr output from a crashing hook and about an onFailure: block setting that hadn't been tested. The first reader's question was answered in the article, which established that a non-2 exit code still lets the guarded tool call through, and that the failure appears as a hook_non_blocking_error attachment.

However, the article did not examine what is actually in the model's context versus what is only visible in the raw session log.

To answer these questions, the author built an experiment using a throwaway .claude/settings.json file, a crash-prone hook script, and real headless Claude -p calls against the actual CLI. The crash_hook.py script logs its invocation time, writes a traceback to a file, and then raises a RuntimeError. The hooks configuration includes a PreToolUse hook for the Bash command, with a matcher and a command to run the crash_hook.py script.

When the command echo hello456 is asked to run, the full event stream is captured with the --output-format stream-json --verbose option. The raw stream contains a hook_response system event with the entire crash information. However, the tool-result message that the model receives does not contain any stderr output, exit code, or mention of the hook running. The model's final answer correctly reports that the command printed hello456 without mentioning any hook output or errors.

When the onFailure: block setting is added to the hook configuration, the result changes. The crash occurs, and the tool call does not go through. The tool-result message now indicates that the tool call was blocked due to the onFailure: block setting, and the model's final answer accurately describes the situation, including the crash details and the blocked command.

This demonstrates that the onFailure: block setting fails closed, while the default behavior fails open, allowing the guarded command to run even if the hook crashes.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A Room With One Door

There is a class of tool now that runs an attack the way a person would, except faster and without getting tired. You give it a target and a goal — "get server access" — and a group of language-model…

  • ARTEX tool simulates autonomous attacks using language-model agents
  • Attack and target isolated in separate virtual machines with single communication path
  • Containment proved challenging due to obstacles in bypassing isolation

把自建文件浏览器装成 Android APK:只有 64 位,而这一点很要命

如果你一天要打开手机上那个下载文件夹五次,问题不在服务器,而在那个文件夹住在浏览器标签页里:手势一划标签就没了,刷新就忘了上次看到哪,地址栏还吃掉半屏。 Banyan 是一个用 Go 单二进制 发布的自建文件浏览器。一个文件、不用 Docker、不用数据库。同一个二进制既在局域网里跑网页界面,也在同一个页面给你下载 Android APK。但有个条件比别的都更浪费时间: APK 只支持 arm64…

More from Friday 20 November →