Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/configuration/hooks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Docker Agent dispatches the following hook events:

| Event | When it fires | Can block? |
| --------------------------- | --------------------------------------------------------------------------------- | ---------- |
| `pre_tool_use` | Default lane: approval helper when the safety mode asks; also vetoes delegation wrappers in balanced; skipped on other auto-approved calls | Yes |
| `pre_tool_use` | Default lane: approval helper when the safety mode asks; also vetoes delegation wrappers in balanced and AG-UI frontend tool calls under every mode; skipped on other auto-approved calls | Yes |
| `tool_input_transform` | Before tool guards, permission rules, and safety classification, including auto-approved calls | Yes |
| `prompt_file_guard` | Before loaded or retained prompt-file instructions enter storage or a model request | Yes |
| `skill_content_guard` | After reading skill text, before expansion or delivery | Yes |
Expand Down Expand Up @@ -444,7 +444,7 @@ In addition to the common fields, each event ships its own payload:
| `user_steering_messages_submit` | `steering_messages` — the drained steering messages, in submission order |
| `user_followup_submit` | `prompt` — the text of the dequeued follow-up message |
| `turn_start` | _none_ (just the common fields) |
| `turn_end` | `agent_name`, `reason` — one of `normal`, `continue`, `steered`, `error`, `canceled`, `hook_blocked`, `loop_detected` |
| `turn_end` | `agent_name`, `reason` — one of `normal`, `continue`, `steered`, `error`, `canceled`, `hook_blocked`, `loop_detected`, `client_tool_calls` |
| `before_llm_call` | `iteration` — 1-based run-loop iteration counter (the model call this hook is gating), `model_id` |
| `after_llm_call` | `agent_name`, `stop_response`, `last_user_message`, `model_id`, `usage`, `cost` |
| `session_end` | `reason` — `stream_ended` |
Expand Down Expand Up @@ -477,7 +477,7 @@ Notes:
- For [harness agents](../../features/harnesses/index.md), `cost` is the harness's own reported total for the call rather than a computed price, and is present only when the harness reported a non-zero cost (some harnesses, e.g. `codex`, report token counts but no cost — those turns carry `usage` with `cost` absent, even though the recorded message stores `0`).
- `after_llm_call` fires for **every** model call, including calls made inside sub-sessions (transferred tasks, background agents, skills). For those, `session_id` is the sub-session's id. Summing `cost` across `after_llm_call` events therefore captures **all** spend, including sub-sessions (and even sub-sessions that error before their cost is persisted). Do **not** add a separately-queried session cost total on top: the runtime's own total already recurses into and includes completed sub-session spend, so combining the two double-counts. Pick one source — the summed hook costs — as the authoritative ledger.
- `context_limit` is `0` when the model definition is unavailable (treat `0` as "unknown", not as a real limit).
- `approval_decision` is one of `allow`, `deny`, `canceled`. `approval_source` is a stable classifier of which step decided (e.g. `yolo`, `session_permissions_allow`, `session_permissions_deny`, `team_permissions_allow`, `team_permissions_deny`, `pre_tool_use_hook_allow`, `pre_tool_use_hook_deny`, `tool_input_transform_deny`, `tool_guard_deny`, `readonly_hint`, `user_approved`, `user_approved_session`, `user_approved_safe`, `user_approved_tool`, `user_rejected`, `context_canceled`).
- `approval_decision` is one of `allow`, `deny`, `canceled`. `approval_source` is a stable classifier of which step decided (e.g. `yolo`, `session_permissions_allow`, `session_permissions_deny`, `team_permissions_allow`, `team_permissions_deny`, `pre_tool_use_hook_allow`, `pre_tool_use_hook_deny`, `tool_input_transform_deny`, `tool_guard_deny`, `readonly_hint`, `client_executed`, `user_approved`, `user_approved_session`, `user_approved_safe`, `user_approved_tool`, `user_rejected`, `context_canceled`).

## Hook Output

Expand Down Expand Up @@ -990,6 +990,7 @@ The `reason` field classifies the exit:
| `canceled` | Context was cancelled (e.g. Ctrl+C) |
| `hook_blocked` | `before_llm_call` or `post_tool_use` denied the call |
| `loop_detected` | The consecutive-tool-call loop detector terminated the turn |
| `client_tool_calls` | The model called tools the client application runs (AG-UI frontend tools): the run stops for the client to answer them |

`turn_end` is observational — the result is ignored. Use it to time turns, accumulate per-turn metrics (token usage, tool counts), or notify external observability pipelines symmetrically with `turn_start`.

Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/permissions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ Permissions work alongside [hooks](../hooks/index.md). The evaluation order is:
3. Run **`preempt_yolo` pre_tool_use hooks** — legacy mandatory checks, with their existing session-grant exception
4. Check **deny** patterns — if matched, tool is blocked
5. Check **allow** patterns — if matched, tool is auto-approved
6. Check **ask** patterns — if matched, the user is prompted directly, skipping the default `pre_tool_use` lane
7. If no rule matched, apply the **[safety mode](#safety-modes)** to the call's safety label — may auto-approve (or, under `restricted`, deny)
6. Check **ask** patterns — if matched, the user is prompted directly, skipping the default `pre_tool_use` lane; a call the client application runs is handed to it without a prompt (step 9)
7. If no rule matched, apply the **[safety mode](#safety-modes)** to the call's safety label — may auto-approve (or, under `restricted`, deny). A call the client application runs (an [AG-UI frontend tool](../../features/ag-ui/index.md#frontend-tools)) is routed to "ask" instead
8. On a mode "ask", run **pre_tool_use hooks** — hooks can allow, deny, or ask
9. If no decision, **ask user** for confirmation
9. If no decision, **ask user** for confirmation; a call the client application runs is handed to it without a prompt

Default-lane hooks only see calls the mode routed to "ask"; they cannot override deny decisions or explicit `ask:` rules. If they rewrite arguments, mandatory checks and permission rules are evaluated again before execution. A new ask during this recheck requires fresh confirmation; earlier grants cannot bypass it. See [tool phases](../hooks/index.md#tool-phases-transform-guard-approve).

Expand Down
Loading
Loading