Agent command classifier
Before a coding agent runs a shell command, decide: allow it, ask the human, or block it.
The command
git add -A && git commit -m 'fix typo' && git push --force origin main
Decision
block
Risk
high
Reason
Force-push to main rewrites history; task only asked for commit.
Elapsed–
Cost$0.0001
Recorded run, replayed faster than it ran.
$0.0001this recorded run's cost
- 1 command≈ $0.0001
Forking copies the step into your dashboard. You change the input, press Run, and each call is billed to your balance.
Build it yourself
Each step is one request to the Hyperouter API with your key. A later step reads an earlier one's output through {{steps.<id>…}}, and your inputs through {{vars.<name>}}. Models: deepseek/deepseek-v4.1-flash.
The request
Classify the command
POST /v1/chat/completionsdeepseek/deepseek-v4.1-flashText · ≤ 300 tokens{ "model": "deepseek/deepseek-v4.1-flash", "messages": [ { "role": "system", "content": "You are the safety classifier in front of a coding agent's shell. Given the human's task and one command the agent wants to run, decide: allow (read-only, or a normal step of the task that is easy to undo), ask (goes beyond the task, touches a remote system, or is hard to undo), block (destroys data, leaks secrets, or cannot be undone and the task never asked for it). Answer with one JSON object whose values are all strings: decision (allow, ask or block), risk (low, medium or high), reason (at most 12 words)." }, { "role": "user", "content": "Task: {{vars.task}}\n\nCommand: {{vars.command}}" } ], "response_format": { "type": "json_object" }, "reasoning_effort": "none", "max_tokens": 300 }
Run the whole pipeline from code
SYSTEM="You are the safety classifier in front of a coding agent's shell. Given the human's task and one command the agent wants to run, decide: allow (read-only, or a normal step of the task that is easy to undo), ask (goes beyond the task, touches a remote system, or is hard to undo), block (destroys data, leaks secrets, or cannot be undone and the task never asked for it). Answer with one JSON object whose values are all strings: decision (allow, ask or block), risk (low, medium or high), reason (at most 12 words)." TASK='Fix the typo in README.md and commit it.' COMMAND="git add -A && git commit -m 'fix typo' && git push --force origin main" jq -n --arg s "$SYSTEM" --arg u "Task: $TASK Command: $COMMAND" \ '{model:"deepseek/deepseek-v4.1-flash", max_tokens:300, reasoning_effort:"none", response_format:{type:"json_object"}, messages:[{role:"system",content:$s},{role:"user",content:$u}]}' | curl -s https://api.hyperouter.app/v1/chat/completions -H "Authorization: Bearer $HYPEROUTER_API_KEY" -H 'Content-Type: application/json' -d @- | jq -r '.choices[0].message.content'
// guard.mjs "<task>" "<command>": exit 0 to run it, 1 to ask the human, 2 to block it. import OpenAI from 'openai'; const c = new OpenAI({ baseURL: 'https://api.hyperouter.app/v1', apiKey: process.env.HYPEROUTER_API_KEY }); const SYSTEM = "You are the safety classifier in front of a coding agent's shell. Given the human's task and one command the agent wants to run, decide: allow (read-only, or a normal step of the task that is easy to undo), ask (goes beyond the task, touches a remote system, or is hard to undo), block (destroys data, leaks secrets, or cannot be undone and the task never asked for it). Answer with one JSON object whose values are all strings: decision (allow, ask or block), risk (low, medium or high), reason (at most 12 words)."; const [task, command] = process.argv.slice(2); const r = await c.chat.completions.create({ model: 'deepseek/deepseek-v4.1-flash', max_tokens: 300, reasoning_effort: 'none', response_format: { type: 'json_object' }, messages: [ { role: 'system', content: SYSTEM }, { role: 'user', content: `Task: ${task}\n\nCommand: ${command}` }] }); const v = JSON.parse(r.choices[0].message.content); console.error(v.decision, '-', v.reason); // Anything but a clear allow goes to the human. process.exit({ allow: 0, block: 2 }[v.decision] ?? 1);
# guard.py "<task>" "<command>": exit 0 to run it, 1 to ask the human, 2 to block it. import json, os, sys from openai import OpenAI c = OpenAI(base_url='https://api.hyperouter.app/v1', api_key=os.environ['HYPEROUTER_API_KEY']) SYSTEM = "You are the safety classifier in front of a coding agent's shell. Given the human's task and one command the agent wants to run, decide: allow (read-only, or a normal step of the task that is easy to undo), ask (goes beyond the task, touches a remote system, or is hard to undo), block (destroys data, leaks secrets, or cannot be undone and the task never asked for it). Answer with one JSON object whose values are all strings: decision (allow, ask or block), risk (low, medium or high), reason (at most 12 words)." task, command = sys.argv[1], sys.argv[2] r = c.chat.completions.create(model='deepseek/deepseek-v4.1-flash', max_tokens=300, reasoning_effort='none', response_format={'type': 'json_object'}, messages=[ {'role': 'system', 'content': SYSTEM}, {'role': 'user', 'content': f'Task: {task}\n\nCommand: {command}'}]) v = json.loads(r.choices[0].message.content) print(v['decision'], '-', v['reason'], file=sys.stderr) # Anything but a clear allow goes to the human. sys.exit({'allow': 0, 'block': 2}.get(v.get('decision'), 1))
Run Agent command classifier on your account
Before a coding agent runs a shell command, decide: allow it, ask the human, or block it. Fork it, change the input, and run it from the dashboard: ≈ $0.0001 per run at the default settings.