Went ahead without asking · 1 of 21 sessions
Make the agent ask before risky commands
A Codex rule makes it ask before each matching command, and its sandbox is enforced by the operating system. Source: Codex docs
What happened
The agent went ahead without asking you first. Agent's mistake
Rule in your AGENTS.md
“Ask before running migrations or anything that writes to the shared staging database.”
What the agent did
AGENTS.md says to ask before migrations; the agent ran one on the shared staging database without asking.
You, then
“You ran that on staging without asking.”
Fixed in the same session, after you pointed it out.
Which session
invoice-sync · Codex · 9fe9a6852b37
Up to 3 cases, picked because they read clearly. Bigger misses and ones that quote your instruction come first. The count above includes every case.
How to fix it
Make Codex ask you before that command with a rule (an experimental feature), and keep approvals on request. → prefix_rule(decision = "prompt") (~/.codex/rules/default.rules), approval_policy = "on-request"
Details
- How often
- In 1 of the 21 checked sessions · 1 event
- How sure
- Check this · found only by the Codex judge, which flags more
Sources
- Official docs: Codex docs: Rules (experimental) · 2026-11-22
“prompt: Prompt before each matching invocation. Codex applies the most restrictive decision when more than one rule matches (forbidden > prompt > allow).” - Official docs: Codex docs: Agent approvals & security · 2026-11-22
“Locally, Codex uses an OS-enforced sandbox that limits what it can touch (typically to the current workspace); approval_policy = "on-request".”