accept allow with claude_cli, fail closed when tool calls are unseen

This commit is contained in:
hermes committed 2026-11-14 10:22:29 +00:00
1 parent 2751bcf27b
commit 80ea84f8f6
6 files changed
+56 -46

No files matched your search

+12 -11
View File
@@ -34,19 +34,20 @@ A repo that already has its own `.hx/config.toml` is refused (`setup:` failure)
## Provider modes
hx has two ways to reach Claude. They differ in what orch can enforce:
hx reaches Claude in two ways:
| mode | who runs the tools | `allow` | `max_turns` |
|---|---|---|---|
| `direct` (API provider) | hx | enforced (guard + stream check) | counts model turns |
| `claude_cli` (hx starts the `claude` binary; auto-on when `claude` is in PATH and `HX_BASE_URL` is unset) | the `claude` binary; hx emits no `tool_call` events and its permission bridge skips reads | cannot be enforced | meaningless: 1 hx request per run |
| mode | who runs the tools | what orch sees |
|---|---|---|
| `direct` (API provider) | hx | every tool as a `tool_call` event |
| `claude_cli` (hx starts the `claude` binary; auto-on when `claude` is in PATH and `HX_BASE_URL` is unset) | the `claude` binary | with johannes/hx#182: every tool as a `tool_call` event, decided by the guard through hx' permission bridge; without it: only a `[claude TOOL: ...]` text line |
A profile with `allow` in `claude_cli` mode is **refused** before hx starts: the run ends `needs-human` with
`policy: allow cannot be enforced ...`. orch never runs "guarded" without a guard and never switches providers
silently (the direct Claude provider is not usable on every subscription). Options for such a profile:
no `allow` plus `sandbox = true`, `home`, the cleared environment; or `claude_cli = false` in the profile's hx config
if the direct provider works for you. Planned: make the claude_cli provider guardable in hx (permission bridge on
the event bus, tool events), see the linked hx issue.
`allow` works in both modes **provided hx reports claude's tools as `tool_call` events** (hx#182). orch checks this
on every run: it counts the `[claude ...]` tool lines in the text stream and the `tool_call` events. If claude used
more tools than hx reported, the run ends `needs-human` with `policy: claude used N tool(s) but hx reported M
tool_call event(s) ...`: a profile is never silently unguarded. On an hx without #182 every claude_cli run that
uses a tool therefore fails closed; the tool has already run by then (the check is after the fact), so on such an hx
use no `allow` plus `sandbox = true` for claude_cli profiles.
`max_turns` counts model turns; in claude_cli mode there is one hx request per run, so it is not a useful limit there.
Telemetry records the mode (`provider_mode`: `claude_cli`, `direct`, `codex`; old lines `unknown`). `orch report`
shows it as a column and `orch eval` refuses to compare files with different (or mixed) modes ("NOT COMPARABLE",