Crush 的工具前钩子:并行检查、按配置顺序合成、可信 shell 边界
Crush 把用户自有 shell 命令挂在工具调用边界:文档化的前置钩子可拦截、改写或审批;钩子并行执行但按配置顺序合成决策,并用嵌入式 shell 承载策略与配置。
模型可以提议一次工具调用,编码代理宿主必须决定它是否真正执行。Crush 把用户自有的 shell 命令挂在这条边界上,而不是只靠提示词里的口头规矩。
据 @vshengbro 对公开文档的整理,已文档化的事件是工具使用前钩子:匹配到的钩子能收到即将发生的工具动作,从而拦截命令、改写输入、补充上下文或参与审批。文档写明其他生命周期钩子仍在规划,因此不能把「有了前置钩子」理解成覆盖代理会产生的一切事件。
调度上并存两种选择:钩子并行跑以减少等待,但结果按配置顺序合成,保证最终解释确定——完成先后不会变成意外的策略优先级。执行侧有可移植约定:无解释器声明的内联命令与脚本走嵌入式 shell;带声明的脚本交给操作系统按解释器分发;仅凭脚本文件名不够时,文档模式要求显式调用解释器。
配置同样走这套 shell:可用命令注册供应商、模型、权限与外部工具端点,必要时分支或引入文件;项目设置覆盖全局,且可被正在使用它的代理改写。于是配置文件变成可执行的可信输入,而不是「随便下载就安全」的被动数据。工程收益是在概率性规划器外加一层确定性控制;成本是要维护真实的策略软件,包括错误行为、可移植性与配置来源可信度。原帖声明未安装钩子、也未做对抗性策略测试。
Crush PreToolUse hooks and trusted shell
Crush: parallel hooks, ordered decisions, and a trusted shell configuration
A model can propose a tool call; a coding-agent host must decide whether that call actually executes. Crush's hooks put user-owned shell commands on that boundary rather than relying only on instructions in a prompt.
The documented event is PreToolUse. A matching hook receives the impending tool action, allowing policy code to block a command, rewrite input, provide context or participate in approval. The documentation explicitly says other lifecycle hooks are planned, so a pre-tool mechanism should not be mistaken for coverage of every event an agent can produce.
Two scheduling choices coexist. Hooks run in parallel to reduce waiting, but their results compose in configuration order to keep the final interpretation deterministic. Completion timing therefore does not become an accidental policy-priority system. That is the useful distinction between executing checks concurrently and applying their decisions nondeterministically.
Execution itself has a portability contract. Crush uses an embedded POSIX shell for inline commands and scripts without a shebang. A script with a shebang dispatches to its named interpreter through the operating system. A PowerShell filename is not automatically sufficient: the documented pattern invokes the interpreter explicitly.
Configuration uses that shell too. A crushrc can register providers, models, permissions and MCP endpoints using commands, with branching or sourced files when necessary. Project settings override global settings, and command-based configuration can be manipulated by the same agent that uses it.
This flexibility moves the trust boundary. A configuration file is executable, trusted input, not passive JSON that is safe to download and load blindly. A hook can only enforce the policy actually written, and its interpreter and external utilities must exist where it runs. Parallel launch does not magically make those programs reliable or harmless.
The engineering payoff is deterministic control around a probabilistic planner, with one configuration vocabulary for people and agents. The cost is maintaining real policy software, including error behavior, portability and trustworthy configuration sources. This post describes the documented execution model; no hook was installed or adversarial policy test run.
Primary sources https://t.co/ndTC1IcUKg https://t.co/7DoJJeloPD https://t.co/ZNhWM6xrFn