Scenario
Two refusals, two wordings, one agent file
RolesAgent Systems EngineeringAI Evaluation and Reliability
- Engine
- docker-agent v1.149.0 and sbx v0.47.0
- Model
- ai/qwen3:4b through the local model runner, at temperature 0
- Hardware
- one Mac, no GPU
Situation
Two tickets arrive on the same morning about one agent file. The file gives an agent a shell toolset, an allow pattern for echo, a deny pattern for rm, and a logging hook on every shell call. Both engineers sent the same three messages: run echo m101-ok, run pwd, run rm -rf work/m101-nothing.
The first engineer runs the agent in a pipeline with --exec --safety restricted. The ticket says that the agent refuses rm with the text Tool 'shell' is denied by permissions configuration and asks for the deny pattern to be removed, because the pipeline needs a cleanup step. The second engineer runs it on a laptop with --exec --safety strict. The ticket says that the agent refuses pwd with the text The user rejected the tool call, that no prompt ever appeared, and that the hook must be broken, because it answers allow on every call. You hold both tickets and the capture of both runs.
Questions
- The two refusals have two wordings. Before you open the agent file, say what each wording tells you about where the decision was made.
- No pattern names
pwd. Why did it run in one mode and not in the other? - The hook answered allow on all three calls. Why did that change nothing, and what could the hook have changed?
- What does the direct tool run prove, and what does it not prove?
- Which ticket reports a bug, which reports the design at work, and what do you change for each?
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the toolset, the hook and the two patterns of the guarded agent
One allow pattern for echo, one deny pattern for rm, and a preempting hook on every shell call.
toolsets:
- type: shell
hooks:
pre_tool_use:
- matcher: shell
preempt_yolo: true
hooks:
- type: command
command: ./fixtures/hooks/log-hook.sh
env:
M101_HOOK_LOG: ./work/hook-stdin.jsonl
permissions:
allow:
- "shell:cmd=echo*"
deny:
- "shell:cmd=rm*"Source: manuals/docker-sandboxes-101/capture/fixtures/agents/guarded.yaml, lines 12-28
the three commands under --safety restricted
Read which commands ran and the wording of the one refusal.
user: Run the shell command: echo m101-ok
root -> tool_call shell {"cmd": "echo m101-ok"}
root <- tool_call_response Shell: m101-ok
root: echo m101-ok
m101-ok
stream_stopped (stop, normal)
user: Run the shell command: pwd
root -> tool_call shell {"cmd": "pwd"}
root <- tool_call_response Shell: $CAPTURE
root: pwd
$CAPTURE
stream_stopped (stop, normal)
user: Run the shell command: rm -rf work/m101-nothing
root <- tool_call_response Shell: Tool 'shell' is denied by permissions configuration.
root: rm -rf work/m101-nothing
The command was refused due to permissions configuration.
stream_stopped (stop, normal)Source: manuals/docker-sandboxes-101/capture/out/20-restricted.txt, lines 1-17
the second and third commands under --safety strict
Compare the wording of the two refusals, and read the metadata of the confirmation.
user: Run the shell command: pwd
tool_call_confirmation: {"agent_name": "root", "tool_call": {"id": "<call-id>", "type": "function", "function": {"name": "shell", "arguments": "{\"cmd\": \"pwd\"}"}}, "metadata": {"blast_radius": "safe", "category": "fs-read", "reason": "Command matches safe read-only pattern: pwd", "safety_label": "safe"}}
root <- tool_call_response Shell: The user rejected the tool call.
root: pwd
The user rejected the tool call.
stream_stopped (stop, normal)
user: Run the shell command: rm -rf work/m101-nothing
root <- tool_call_response Shell: Tool 'shell' is denied by permissions configuration.
root: rm -rf work/m101-nothing
Tool 'shell' is denied by permissions configuration.
stream_stopped (stop, normal)Source: manuals/docker-sandboxes-101/capture/out/20-strict.txt, lines 7-17
the three records the hook wrote, one per call
Every call reached the hook, including the one that was refused.
{"agent_name": "root", "cwd": "$CAPTURE", "hook_event_name": "pre_tool_use", "safety_policy": "restricted", "session_id": "<uuid>", "tool_input": {"cmd": "echo m101-ok"}, "tool_name": "shell", "tool_use_id": "<call-id>"}
{"agent_name": "root", "cwd": "$CAPTURE", "hook_event_name": "pre_tool_use", "safety_policy": "restricted", "session_id": "<uuid>", "tool_input": {"cmd": "pwd"}, "tool_name": "shell", "tool_use_id": "<call-id>"}
{"agent_name": "root", "cwd": "$CAPTURE", "hook_event_name": "pre_tool_use", "safety_policy": "restricted", "session_id": "<uuid>", "tool_input": {"cmd": "rm -rf work/m101-nothing"}, "tool_name": "shell", "tool_use_id": "<call-id>"}Source: manuals/docker-sandboxes-101/capture/out/20-hook-stdin.jsonl, lines 1-3
the hook script
The hook logs the record and answers allow on every call.
#!/bin/sh
input=$(cat)
printf '%s\n' "$input" >> "${M101_HOOK_LOG:-/dev/null}"
printf '%s\n' '{"hook_specific_output":{"permission_decision":"allow","permission_decision_reason":"logged by fixtures/hooks/log-hook.sh"}}'Source: manuals/docker-sandboxes-101/capture/fixtures/hooks/log-hook.sh, lines 1-4
the shell tool called directly, with no model in the loop
The exit code tells you whether the tool itself works.
$ docker-agent debug tool fixtures/agents/guarded.yaml shell '{"cmd":"echo m101-direct"}'
m101-direct
[exit 0]Source: manuals/docker-sandboxes-101/capture/out/20-debug-tool.txt, lines 1-3
the order the runtime applies to every tool call
Find the step that decided each of the three commands.
1. `preempt_yolo` `pre_tool_use` hooks run first, and no mode or allow rule can bypass their deny or ask.
2. A `deny` pattern blocks the call.
3. An `allow` pattern approves it.
4. An `ask` pattern prompts the user.
5. With no match, the safety mode applies to the call's label.
6. On a mode ask, default `pre_tool_use` hooks can allow, deny, or ask.
7. With no decision, the user is asked.Source: manuals/docker-sandboxes-101/sections/5-5-permissions-safety-and-hooks.md, lines 86-92
The answer
Show the walkthrough
- Read the agent file. One toolset of type
shell. Apre_tool_usehook withmatcher: shellandpreempt_yolo: true, which runs a script. Underpermissions,allowholdsshell:cmd=echo*anddenyholdsshell:cmd=rm*. Nothing namespwd. - Read the restricted run.
echoran and printedm101-ok.pwdran and printed the working directory. Thermcall never reached a tool: the response says that the configuration denies the tool. That is thedenypattern, which matchesrm*. - Read the strict run.
echoran again. Forpwd, the runtime raisedtool_call_confirmationwith metadatablast_radius: safe,category: fs-read, andsafety_label: safe. Understrict, every label asks. With--execthere was no terminal, so the ask became a rejection, and the model got a message that said the user rejected the call. Thermcall got the same denial as in the other mode. The two wordings mark two decision points: a denial names the policy, and a rejection names the person who was asked. - Read the hook records and the script. The hook wrote three records in the restricted run, one per call, including the
rmcall. The records carrysafety_policy: restrictedand the fulltool_input. The script appends the record and printspermission_decision: allow. The order of decisions puts preempting hooks first, and from there an allow is advice only: a deny or an ask from the hook would have ended the call, an allow does not grant it. The deny pattern then blockedrmat the second step. - Read the direct tool run.
debug toolcalled the shell tool of the same agent file withecho m101-directand printedm101-directwith exit 0. The tool works. The refusals are decisions, not tool failures. The direct run does not say what the model would call, so it closes only the question about the toolset. - Map each command to the order.
echo: step three, an allow pattern.rm: step two, a deny pattern, in both modes.pwd: no pattern, so step five, the safety mode on the labelsafe:restrictedallows a safe label, andstrictasks.
Show the resolution
The first ticket describes the policy doing its job. A deny pattern blocks the call in every mode, and the manual's order places it above every allow, every ask, and every mode. Keep the pattern. A pipeline that must delete files does that outside the agent, or with a narrower deny that still excludes rm -rf. Removing the one rule that no mode and no hook can override leaves an unattended agent with no gate.
The second ticket reports a mode that does not fit an unattended run. strict asks on every unmatched call, and --exec without a terminal turns every ask into a rejection. The fix is --safety restricted for the laptop run, which lets a safe label run and refuses destructive and unknown, or an allow pattern for pwd. The hook is not broken: a preempting hook grants nothing, and its log of three records shows that it saw every call. The proof is the restricted run: pwd printed the working directory, rm stayed refused, and the hook recorded all three.
One line from the manual belongs in both ticket replies: the client enforces permissions, they stop accidents, and they are not a security boundary. For an agent you do not trust, run it in a sandbox.
Show the wrong turns
“The hook is broken, because it returned allow and the call was still refused.”
From a preempting hook an allow verdict is advice. Its deny or ask would have ended the call. Nothing is broken.
“Remove the deny pattern so the cleanup step runs in the pipeline.”
The deny is the one rule that no mode and no hook can override. An unattended agent with
rmallowed has no gate left.“Run with
--yoloso nothing asks.”That is
autonomous: every unmatched call runs,destructiveandunknownincluded. Thepwdcase needsrestrictedor one allow pattern.“The shell toolset is misconfigured on the laptop.”
The direct run printed
m101-directwith exit 0 against the same agent file. The tool works, and the decision layer refused.
Show the general rule
Read the wording of a refusal first. A denial names the policy, a rejection names the user, and a prompt in a headless run becomes a rejection. Then map each call to the decision order: preempting hooks, deny, allow, ask, mode. Choose the mode by who is watching the terminal, and remember that none of this is a security boundary.
Taught in
The permissions section runs these three commands in both modes and gives the decision order.