This is the mode to use when you do not yet know what an agent will do with a task — which is most first runs, and every run on material you did not write.
What is asked
| Category | In ask mode |
|---|---|
read · memory · task | allowed, never asked |
write | asked — and always remembers that tool for the session |
| exec | asked — always on a plain command is written to disk |
storage | asked — always is per storage, for the session |
dns | asked — always is per domain, for the session |
send · publish · money | asked every time, no always |
const agent = api.agents.create({
runtime: "local",
machine: pc,
model: "gemini-3.5-flash",
mode: "ask",
onPermission: async ({ tool, category, args }) => {
if (category === "exec") return "deny"; // no commands at all
if (tool === "write" && args.path.startsWith("src/")) return "always";
return "once";
},
});def on_permission(request):
if request["category"] == "exec":
return "deny" # no commands at all
if request["tool"] == "write" and request["args"].get("path", "").startswith("src/"):
return "always"
return "once"
agent = api.agents.create(
runtime="local",
machine=pc,
model="gemini-3.5-flash",
mode="ask",
on_permission=on_permission,
)Without a callback it can only read
The refusal is explicit — « this action needs the user's approval and no one can approve it » — and it goes back to the model, which adapts. So an agent in ask mode with no callback behaves close to plan mode, without saying so in its instructions.
A refusal is information
deny is not an error: the tool returns « Refused by the user. » as its result and the loop continues. The model is told not to retry a refused tool, and to adapt or explain instead.