Hooks: Protocol, Order and Merge
Status: 2026-11-16. Built: everything in sections 1–7 (pkg/plugin/hooks.go, hookpoints.go, rewrite.go; internal/bundle/hooks.go, hookroles.go, hookpoints.go, shared.go; internal/ho
Status: 2026-11-16. Built: everything in sections 1–7 (pkg/plugin/hooks.go, hookpoints.go, rewrite.go; internal/bundle/hooks.go, hookroles.go, hookpoints.go, shared.go; internal/host/engine/hookpoint.go, hooks.go, guards.go, rewrite.go, steps.go, observe.go; internal/host/observed; tests TestHooksMergeAndAsk, TestHooksRunAtOnceAndDedup, TestContextAndStopEvents, TestReviewAndPreCompact, TestFailureAndObserveHooks, TestP2Hooks, TestRewriteFromUpdatedInput, TestHookEventNeedsItsRole, TestHookBudget, TestOperatorLayerGatesFirst, TestGatesRunInParallel, TestHookPluginsRunInUsesOrder, TestRewriteChain, TestRewriteVoidsAnEarlierApproval, TestToolNarrowingAndModelGuards, TestObserverReceivesCommittedFacts, TestStepCheck, TestCommandHooks). Section 8 compares other agents; section 9 lists what is not supported; section 10 maps DSH plugins. This is the reference a plugin author reads to know what a hook receives, what it may answer, and in what order hooks run. The wider extension surface is in extension points; the plugin forms are in the plugin design. The design behind order, layers and the newer hook points is the hook model.
1. Two Kinds of Hook Points
| Kind | Declared by | Implemented as | Contract |
|---|---|---|---|
| Code roles | roles: in plugin.yaml | Go interfaces (builtin plugins) or JSON-RPC methods (process plugins, any language) | pkg/plugin/roles.go, pkg/plugin/extensions.go, pkg/plugin/rpc/methods.go |
| Command hooks | hooks: in a manifest plugin's plugin.yaml | A command that reads JSON on stdin and answers on stdout, in Claude Code's protocol | pkg/plugin/hooks.go; run by internal/bundle/hooks.go, mapped to roles in internal/bundle/hookroles.go |
The code roles that act as hooks:
| Role | Method (JSON-RPC) | When | Power |
|---|---|---|---|
guard | guard/check | Before each tool call | Deny, or ask for a person's approval |
guard | guard/check_input | Before a runtime sees the input | Refuse the run |
guard | guard/check_result | After each tool result | Withhold the result or add a note |
guard | guard/check_completion | On a final answer (of the agent or a sub-agent), one cut off at the continuation limit or stopped by the provider's filter included (2026-12-05): those can be withheld, not sent back for more work | Ask for more work |
guard (optional Rewriter) | guard/rewrite | Before the gate phase of each tool call | Replace the arguments (needs grants: [rewrite], ADR 0005) or refuse the call |
guard (optional ToolNarrower) | guard/filter_tools | When a run lists its tools | Remove tools from the run (never add) |
guard (optional ModelGuard) | guard/before_model, guard/after_model | Around each model call | Refuse the call; rewrite its messages or the response text (rewrite grant) |
guard (optional StepGuard) | guard/check_step | After a settled batch of tool calls, before the next model call; a runtime asks through host/check_step | Add context, or stop the run |
context | context/get | Once at run start | Add reference items |
reviewer | reviewer/review | On a call that needs approval, with grants: [review] | Approve, deny or escalate to a person |
observer | observer/observe, observer/before_compact | After a fact is committed (section 7); before a session compaction | Read; name facts a summary must keep |
compactor | compactor/compact | When a session is compacted | Write the summary |
context_processor | processor/process | When history is assembled | Return typed edits |
A command hook is a code role without code: each event fills exactly one role, and the bundle adapter implements that role's method by running the commands.
2. Events and the Roles They Fill
| Event | Wire name (hook_event_name) | Role | Runs | Matcher subject |
|---|---|---|---|---|
pre_tool | PreToolUse | guard | Before each tool call, after the agent's own rules | Tool name |
post_tool | PostToolUse | guard | After each tool result, before the model sees it | Tool name |
user_input | UserPromptSubmit | guard | Before the runtime sees the input | — |
stop | Stop | guard | On the agent's final answer | — |
subagent_stop | SubagentStop | guard | On a delegated sub-agent's final answer | — |
session_start | SessionStart | context | At the start of the first run of a session | — |
pre_compact | PreCompact | observer | Before a session compaction (automatic or /compact) | — |
permission_request | PermissionRequest | reviewer | When a call needs approval, before a person is asked | Tool name |
post_tool_failure | PostToolUseFailure | guard | After a failed tool call, instead of post_tool | Tool name |
session_end | SessionEnd | observer | After a session closed (fact session.closed) | — |
post_compact | PostCompact | observer | After a session compaction (fact compaction.done) | — |
notification | Notification | observer | When a question is shown to a person (fact question.asked) | — |
tool_selection | BeforeToolSelection | guard | When a run lists its tools | — |
before_model | BeforeModel | guard | Before each model call of the run, including summaries | — |
after_model | AfterModel | guard | After each settled model response | — |
after_tool_batch | PostToolBatch | guard | After a batch of tool calls is settled, before the next model call | — |
Wire names follow Claude Code, except BeforeToolSelection, BeforeModel and AfterModel, which follow Gemini CLI. The importer converts Claude Code's PreToolUse, PostToolUse, PostToolUseFailure, UserPromptSubmit, Stop, SubagentStop, SessionStart, SessionEnd, PreCompact, PostCompact, Notification and PermissionRequest.
Validation. The manifest must declare the role each of its hook events fills; otherwise loading fails with manifest <name>: <event> hooks need the <role> role. Every hook needs a known event and a command, match must compile, and on_error is deny or ignore. The importer adds the roles of the events it converts.
3. Declaration
name: release-policy
execution: manifest
roles: [guard, context, reviewer]
hooks:
- {event: pre_tool, match: "bash|write", command: [python3, "${PLUGIN_ROOT}/pre.py"], timeout: 30s}
- {event: session_start, command: [python3, "${PLUGIN_ROOT}/brief.py"]}
- {event: permission_request, match: deploy, command: [python3, "${PLUGIN_ROOT}/approve.py"], on_error: ignore}| Field | Meaning |
|---|---|
event | One of section 2 |
match | For pre_tool, post_tool, post_tool_failure, permission_request. Empty or * matches every tool; anything else is a regular expression over the whole name, case-insensitive (bash|write). Other events ignore it |
command | Argument list, run without a shell; ${PLUGIN_ROOT}, ${PLUGIN_DATA} and ${option.KEY} are expanded |
timeout | Go duration; default 10s |
on_error | deny (default) or ignore, see section 6 |
Tool names are the names the model sees: builtin tools by their name (bash, read), MCP tools as <instance>__<tool>. A Claude Code matcher such as mcp__memory__.* does not match them and must be rewritten for the instance id.
Environment. The working directory is the instance's data directory (PLUGIN_DATA), so what a command writes where it runs, a log or a rule file, is no change to the approved plugin files (Feishu #243); a leading ./ in the command names the plugin's own file. The command receives PLUGIN_ROOT, PLUGIN_DATA, CLAUDE_PLUGIN_ROOT, CLAUDE_PLUGIN_DATA, CLAUDE_PROJECT_DIR (the plugin directory), CLAUDE_PLUGIN_OPTION_<KEY> for each option, and the small environment allowlist MCP servers get. policy.mcp_commands limits which executables may run.
4. Payloads and Answers
Every payload carries:
| Field | Value |
|---|---|
hook_event_name | The wire name |
session_id | The run's session (ss_…); the run id when the run has no session |
run_id | The run |
transcript_path | Always "": the session log is not a file a script can read |
cwd | The working directory: the instance's data directory |
permission_mode | Always "default" |
A hook answers in one of three ways:
| Answer | Meaning |
|---|---|
| Exit 0, empty stdout or non-JSON stdout | No opinion |
| Exit 0, JSON on stdout | Read as below |
| Exit 2 | Block; stderr is the reason (blocked by a <event> hook when empty) |
Any other exit, a timeout, or stdout starting with { that is not valid JSON | Failure (section 6) |
JSON fields read: decision: "block" with reason; hookSpecificOutput.permissionDecision deny / ask / allow with permissionDecisionReason; hookSpecificOutput.additionalContext; for permission_request, hookSpecificOutput.decision.behavior allow / deny with message; hookSpecificOutput.updatedInput (pre_tool), allowedTools (tool_selection), updatedMessages (before_model) and updatedResponse (after_model). Within one plugin the last rewrite in manifest order wins. Other fields are ignored.
4.1 Per event
| Event | Own payload fields | Block / deny | Ask | Allow | additionalContext |
|---|---|---|---|---|---|
pre_tool | tool_name, tool_input, tool_use_id | The call is refused; the reason goes to the model | The call needs a person's approval; the reason goes to the approver | No opinion (cannot relax another decision); updatedInput replaces the arguments with the rewrite grant | Note on this call's result |
post_tool | as pre_tool, plus tool_response: {content, is_error} | The reason is added as a note (the result is not withheld) | — | — | Note on the result |
user_input | prompt | The run is refused (input.denied) | Refused too: there is no call to approve | — | Context item of this run (needs the context role): reference, or instruction from the operator layer |
stop | prompt, last_assistant_message, stop_hook_active (true from round 2) | The reason is fed back and the agent works more | Treated as block | — | — |
subagent_stop | as stop, plus agent_type (the sub-agent's name) | As stop, for the sub-agent | Treated as block | — | — |
session_start | source: startup (first session or after a pause) or clear (after /new) | — | — | — | Context item of this run: reference, or instruction from the operator layer |
pre_compact | trigger: auto or manual; custom_instructions: "" | Not possible: compaction always proceeds | — | — | Each line is a fact the summary must keep |
permission_request | tool_name, tool_input, tool_use_id | Denied, as by a reviewer | — | Approved, as by a reviewer | — |
post_tool_failure | tool_name, tool_input, tool_use_id, error (the failed result's text) | The reason is added as a note | — | — | Note on the result |
session_end | reason: idle, reset or another close reason | Answers are ignored | — | — | Ignored |
post_compact | trigger: auto | Answers are ignored | — | — | Ignored |
notification | message (the question's prompt; empty unless the instance has grants: [conversation], P11), notification_type: permission_prompt (approval) or elicitation_dialog | Answers are ignored | — | — | Ignored |
tool_selection | tools: the names the run would see | — | — | allowedTools lists what this plugin allows; tools outside every list are removed | — |
before_model | purpose, messages (the request) | The model call is refused (model.denied_by_policy) | Treated as block | updatedMessages replaces the messages, with the rewrite grant | — |
after_model | purpose, response: {content, tool_calls, stop_reason} (tool_calls are names) | The response is refused (model.denied_by_policy) | Treated as block | updatedResponse replaces the text, with the rewrite grant | — |
after_tool_batch | tool_calls: [{tool_name, tool_use_id, is_error}], agent_type for a sub-agent | The run stops with the reason | Treated as block | — | Shown to the model before its next call |
Feedback from stop and subagent_stop is limited to two rounds per answer (MaxChecks, plugins/agent/loop.go). When a pre_tool hook rewrites the arguments, the same hooks run again in the gate phase on the final arguments; when nothing changed, the gate reuses the first run.
4.2 Examples
// pre_tool, stdin
{"hook_event_name":"PreToolUse","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_name":"bash","tool_input":{"command":"kubectl apply -f prod.yaml"},"tool_use_id":"tc_3b8e01d2aa"}
// stdout: ask a person
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"applies to production","additionalContext":"prod changes need a ticket id"}}// post_tool, stdin
{"hook_event_name":"PostToolUse","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_name":"read","tool_input":{"path":"go.mod"},"tool_use_id":"tc_51aa0c9e12","tool_response":{"content":"module example.com/app","is_error":false}}
// stdout
{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"go.mod is generated; edit tools.go instead"}}// user_input, stdin
{"hook_event_name":"UserPromptSubmit","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","prompt":"deploy v2.3 to prod"}
// stdout: refuse
{"decision":"block","reason":"deploys are frozen until Monday"}// stop, stdin
{"hook_event_name":"Stop","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","prompt":"summarize the incident","last_assistant_message":"The outage was caused by…","stop_hook_active":false}
// stdout: ask for more work
{"decision":"block","reason":"add a line with the incident ticket"}// subagent_stop, stdin
{"hook_event_name":"SubagentStop","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","prompt":"find the failing test","last_assistant_message":"TestLogin fails","stop_hook_active":false,"agent_type":"explorer"}
// stdout: accept
{}// session_start, stdin
{"hook_event_name":"SessionStart","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","source":"startup"}
// stdout
{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"On-call this week: Li Wei"}}// pre_compact, stdin
{"hook_event_name":"PreCompact","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","trigger":"manual","custom_instructions":""}
// stdout: two facts to keep
{"hookSpecificOutput":{"hookEventName":"PreCompact","additionalContext":"Release branch is release/2.3\nTicket OPS-4411 is open"}}// permission_request, stdin
{"hook_event_name":"PermissionRequest","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_name":"deploy","tool_input":{"env":"staging"},"tool_use_id":"tc_9d02e7b4c1"}
// stdout: approve
{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}// pre_tool, stdin (rewrite)
{"hook_event_name":"PreToolUse","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_name":"write","tool_input":{"path":"/etc/hosts","content":"x"},"tool_use_id":"tc_77e0a1c2b9"}
// stdout: rewrite (needs grants: [rewrite])
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow","updatedInput":{"path":"workspace/hosts","content":"x"}}}// post_tool_failure, stdin
{"hook_event_name":"PostToolUseFailure","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_name":"bash","tool_input":{"command":"go test ./..."},"tool_use_id":"tc_2c90d1e4f0","error":"exit status 1"}
// stdout
{"hookSpecificOutput":{"hookEventName":"PostToolUseFailure","additionalContext":"run make generate before the tests"}}// session_end, stdin
{"hook_event_name":"SessionEnd","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","reason":"idle"}
// stdout: ignored
{}// post_compact, stdin
{"hook_event_name":"PostCompact","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","trigger":"auto"}
// stdout: ignored
{}// notification, stdin
{"hook_event_name":"Notification","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","message":"Allow deploy with {\"env\":\"prod\"}?","notification_type":"permission_prompt"}
// stdout: ignored
{}// tool_selection, stdin
{"hook_event_name":"BeforeToolSelection","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tools":["read","grep","bash","write"]}
// stdout: no shell or writes here
{"hookSpecificOutput":{"hookEventName":"BeforeToolSelection","allowedTools":["read","grep"]}}// before_model, stdin
{"hook_event_name":"BeforeModel","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","purpose":"","messages":[{"role":"user","content":"my token is sk-123"}]}
// stdout: redact (needs grants: [rewrite])
{"hookSpecificOutput":{"hookEventName":"BeforeModel","updatedMessages":[{"role":"user","content":"my token is [redacted]"}]}}// after_model, stdin
{"hook_event_name":"AfterModel","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","purpose":"","response":{"content":"Done.","tool_calls":null,"stop_reason":"end_turn"}}
// stdout: rewrite the text (needs grants: [rewrite])
{"hookSpecificOutput":{"hookEventName":"AfterModel","updatedResponse":"Done. (reviewed)"}}// after_tool_batch, stdin
{"hook_event_name":"PostToolBatch","session_id":"ss_7f2a","run_id":"rn_91c4","transcript_path":"","cwd":"/plugins/release-policy","permission_mode":"default","tool_calls":[{"tool_name":"write","tool_use_id":"tc_5a1f9e0b37","is_error":false}]}
// stdout: context for the next model call; {"decision":"block","reason":"…"} would stop the run
{"hookSpecificOutput":{"hookEventName":"PostToolBatch","additionalContext":"run the tests before the next edit"}}5. Order and Merge (normative)
Within one instance. All hooks of the event whose matcher matches run at once, on the same input; none is skipped because another blocked. Identical hooks (same event, matcher, expanded command and options) run once, also across instances asked for the same input (internal/bundle/shared.go). Their answers merge in manifest order:
- ◆Verdicts:
deny(block) >ask>allow> no opinion. The strictest wins. - ◆Reasons: those of the strictest verdict are kept, in order, joined with
"; ". - ◆
additionalContext: every hook's, in hook order, joined with newlines.
Across instances: two layers (hook model section 3). First the operator layer, the instances in policy.hooks of the Host configuration, which every runtime asks whether or not it uses them; then the runtime layer, the instances in the runtime's uses (for tool calls, those of every instance in the call chain), each once. policy.hooks_only: true asks the operator layer only. Inside a layer every instance is asked at once; answers are combined in declared order (policy.hooks order, then uses order). For gates (guard, input guard, reviewer) a layer that denies ends the point: the next layer is not asked. Context from the operator layer reaches the model as instructions (<orq:operator>); context from the runtime layer stays reference material (<orq:reference>).
| Point | Merge |
|---|---|
Guards (check) | Any deny denies; every ask is collected and the call needs approval by the strictest approver; nothing relaxes a deny |
| Result guards | Any withhold withholds; notes are appended in order |
| Input guards | Any deny or ask refuses the run |
| Completion guards | All feedback is collected |
| Reviewers (granted only) | Any deny denies; approval needs every reviewer to approve; anything else goes to a person |
| Context providers | Items in uses order |
| Compactors | Tried in the configured order; the first success wins |
| Context processors | Applied in uses order |
Observers, before_compact | Independent; facts to keep are collected |
Rewriters (guard/rewrite) | A chain, not parallel: the runtime layer in uses order (every instance in the call chain), then the operator layer last, each on the previous arguments; only instances with grants: [rewrite] change them; then the final arguments are schema-checked, gated and approved (ADR 0005) |
Tool filters (guard/filter_tools) | The run keeps the tools every filter allows (intersection); a filter cannot add |
Model guards (guard/before_model, after_model) | A chain like rewriters; any deny refuses the call; rewrites need the grant |
Step guards (guard/check_step) | Context collected in declared order; any stop stops the run |
No priority field. Because every merge is strictest-wins or collect-all, order never changes a verdict; it only orders notes and context, and authority comes from the layer. Claude Code, Codex, Kimi and Crush also run matching hooks in parallel; nine of ten reviewed agents have no priority field (review).
6. Timeouts and Failure
Timeouts. Each hook has its own timeout (default 10 s). The Host bounds each instance's role call by the larger of its own default and that instance's longest hook timeout for the event plus one second (hookBudget, internal/host/engine/guards.go), so a declared timeout always holds; hooks run at once, so the longest one counts. policy.hook_budget (default 60 s) caps a whole hook point.
| Role call | Host default |
|---|---|
context/get (session_start) | 5 s |
guard/check (pre_tool) | 5 s |
guard/check_input, check_result, check_completion | 10 s |
reviewer/review (permission_request) | 30 s |
observer/before_compact (pre_compact) | 30 s |
guard/rewrite (pre_tool rewrites) | 5 s |
guard/filter_tools, before_model, after_model, check_step | 10 s |
observer/observe (session_end, post_compact, notification) | 2 min |
Failure. A hook that cannot start, exits with a code other than 0 or 2, times out, or prints invalid JSON has failed:
- ◆
on_error: deny(default): it counts as a block whose reason names the hook (the pre_tool hook 2 of release-policy could not run). Native hooks fail closed. - ◆
on_error: ignore: it has no opinion; the failure is logged (hook.failed).
Hooks imported from Claude Code or Codex packages get ignore, matching those tools, where a failing hook does not block.
A role call that fails as a whole follows the role's rule: guards deny, input guards refuse, result guards withhold, completion checks are skipped, reviewers escalate, context is omitted, observers are retried; rewriters and model guards refuse the call (fail closed); tool filters and step guards are skipped and logged. Inside a plugin, a failing after_tool_batch hook with on_error: deny counts as a block, so it stops the run.
7. Where Hook Output Goes
| Output | Reaches | Held where |
|---|---|---|
pre_tool block | The model, as the refused call's result | — |
pre_tool context (not blocked) | Note on that call's result | Bundle memory keyed by run and call, until the result; at most 256 held |
post_tool context and block reason | Note on the result | — |
user_input context | Context item of that run: <orq:reference>, or <orq:operator> from the operator layer | Bundle memory keyed by run, read by context/get; never read if the plugin lacks the context role |
session_start context | Context item of the session's first run, as for user_input | — |
stop / subagent_stop block | Feedback that asks for more work | — |
pre_compact context lines | Facts the summary must keep | — |
permission_request verdict | The approval | — |
pre_tool updatedInput (rewrite grant) | The arguments the call runs with; the model's result ends with a note naming who changed them | The ledger keeps the model's arguments; the final ones go to the log (tool.rewritten) |
post_tool_failure context and block reason | Note on the failed result | — |
session_end, post_compact, notification answers | Nowhere: these hooks observe | — |
tool_selection allowedTools | The run's tool list; a removed tool is refused if called (Tool … is not available in this task.) | Host memory of the run |
before_model / after_model block | The model call fails with model.denied_by_policy, which fails the run | — |
before_model updatedMessages, after_model updatedResponse | The request sent, or the response the runtime gets | — |
after_tool_batch context | Before the next model call: <orq:reminder kind="step">, or <orq:operator> from the operator layer | The run's checkpoint |
after_tool_batch block | The run ends with Stopped by the operator's policy: <reason> | — |
Observed facts. session_end, post_compact and notification run from the observer pipeline. The Host appends each committed fact to the observed_events log in the transaction that commits it (internal/host/observed): run.finished, session.opened, session.closed, tool.finished, question.asked, question.settled, compaction.done, delivery.sent, delivery.failed (pkg/plugin/decisions.go). Each observer reads the log from its own durable cursor (observer_cursors.seq), so it gets every fact at least once and in order; a new observer starts at the end of the log. An observer sees the facts of the runtimes that use it; one in policy.hooks sees every runtime's. Either way only the facts of runs its scope (and works_with, owner) covers, as for its other calls; user.forgotten, of no run, reaches it regardless (Feishu #383). A session.closed fact names the person its session.opened named, so a scope that covers one covers the other (Feishu #400). Observers ignore types they do not use.
8. Compared With Other Agents
| Claude Code | Codex | DSH (hooks-claude-code over hook-protocol) | Orquelo | |
|---|---|---|---|---|
| Events | 30 | PreToolUse, PostToolUse, UserPromptSubmit, Stop, PermissionRequest and others (codex-source review) | 7: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, SubagentStart, SubagentStop | 16 (section 2) |
| Handler types | command, http, prompt, agent, mcp_tool | command; executor hooks call MCP tools | command only | command only |
| Order | Parallel, identical handlers deduplicated | Not reviewed | Serial, config order | Parallel within a plugin and within a layer; operator layer, then runtime layer; identical hooks run once; rewrites chain |
| Merge | Deny wins | Not reviewed | deny > ask > allow; context in order; first continue:false sticky | deny > ask > allow; context in order |
| Failure | Non-blocking (exit ≠ 2) | Not reviewed | Non-blocking | Per hook: deny (default) or ignore; imported hooks ignore |
| Default timeout | 600 s | Not reviewed | 600 s | 10 s, Host bound grows with it |
| Argument rewrite | updatedInput | PreToolUse can change arguments | Parsed, not honored | updatedInput from pre_tool, only for instances with grants: [rewrite]; a deterministic chain, then schema check, gates and approval on the final arguments (ADR 0005) |
| Shell | Yes | Yes | Via its shell executor | No; commands needing one are refused at import |
Sources: the compatibility and Codex reviews; the DSH hook-protocol and hooks-claude-code READMEs read from deepseek-ai/deepseek-harness master on 2026-11-16.
9. Not Supported
| Item | Why |
|---|---|
updatedMCPToolOutput | Not read. updatedToolOutput is built: a post_tool or post_tool_failure hook of an instance with grants: [rewrite] replaces the result's text (a string, or an object with content); rewrites chain, the runtime layer first and the operator last, before result guards; a failing rewriter withholds the result; the model is told who changed it (guard/rewrite_result, ADR 0005) |
http, prompt, agent, mcp_tool hook types | An HTTP or model-backed check is a process plugin with the guard or reviewer role; the importer leaves these out with a note |
continue: false, stopReason, systemMessage, suppressOutput | No run-level halt from a hook; cancelling a run is a person's or operator's action |
PreCompact veto | Vetoing compaction ends in context overflow; a hook only names facts to keep |
Blocking from session_end, post_compact or notification | They run after the fact is committed, from the observer pipeline; their answers are ignored |
Other Claude Code events (Setup, InstructionsLoaded, UserPromptExpansion, MessageDisplay, PostToolBatch, PermissionDenied, TaskCreated, TaskCompleted, StopFailure, TeammateIdle, ConfigChange, CwdChanged, FileChanged, WorktreeCreate, WorktreeRemove, Elicitation, ElicitationResult, SubagentStart) | Left out by the importer with a note (after_tool_batch is native only: its wire name matches PostToolBatch, but the importer does not map it). Committed facts reach observer plugins through the observed facts (section 7) |
| A readable transcript | transcript_path is empty; a hook that needs history is a process plugin calling host/session_entries |
10. DSH Plugins Mapped to v2
| DSH plugin | What it does | v2 route | Status |
|---|---|---|---|
hooks-claude-code, hooks-codex, hook-protocol | Run existing hooks.json command hooks | Import the package (orquelo plugin install); hooks become command hooks of a manifest plugin | Built |
mcp-client, mcp-manager | Connect MCP servers, manage them | mcp_servers of a manifest plugin; orquelo plugins -c shows each server's status | Built |
mcp-resources | MCP resources | Resources and prompts | Partly built (B8; internal/bundle/resources.go, prompts.go) |
skill, skill-filesystem, skill-office | Skills from directories; office document skills | skills: of a manifest plugin (Agent Skills layout); office skills install as skills, their tools come from localenv or a tool plugin | Built (skills); office tools not provided |
guard/repeat-tool-reminder | Remind on repeated tool calls | Loop guard inside the agent (plugins/agent/loopguard) | Built |
guard/timeout-policy | Time limits per tool | call_timeout of an instance; run timeouts of the Host | Built |
browser-use-* | Browser control through MCP or native drivers | The agent-browser CLI and its own guide, driven through the shell; the agent-browser plugin declares it (P87 S6). An MCP server such as @playwright/mcp also runs as a manifest plugin; exclusive use of one browser by one run is B17 | Built; exclusivity not built |
computer-use-*, cua-* | Desktop control | A tool plugin with platforms: [darwin] | Not built |
subagent, tool-subagent-oar | Delegate to child agents | delegate tool with subagents in the agent config (P8) | Built (config-defined); plugin-supplied agents not built (B13) |
plugin-market-bundle | Install from plugin indexes | orquelo plugin install from a catalog name, a directory, git+URL#commit or an https archive with sha256 | Built; no index or marketplace |
web-fetch-http, tool-web | Bounded HTTP fetch tool | webfetch builtin plugin (host allowlist, named connections) | Built |
session-persistence-jsonl | Session log storage | The Host's session store (P49); not a plugin role | Built (in the Host) |
todo, plan, goal | Task lists and plans | todo builtin tool of the agent | todo built; plan and goal not built |
schedule, jobs, workflow | Timed runs, background jobs, workflows | Long tools with Pending polling; background shell jobs in localenv; a scheduler or workflow is a trigger or runtime plugin | Jobs built; schedule and workflow not built |