Repository navigation
Description
Summary
Add a new agent mode, auto-with-judge: no human in the loop, but instead of bypassing approval like Auto-Accept, the tool calls that would normally prompt a human are approved or rejected by a small LLM judge. The judge is handed the user's intent (the latest real user message) and the pending tool call, and answers one question: does this action serve the user's intent, and is it safe? A rejection flows through the existing rejection path, so the driver sees the reason and adjusts.
Disabled by default. Nothing changes for standard / plan / auto users.
Motivation: infer-action#340 prototyped a post-run judge that scores a finished run from a transcript digest. A post-hoc judge can only write a report. In the approval gate it can stop a destructive or off-intent command before it runs, it only pays for the calls that are actually risky (allow-listed commands never reach it), and every consumer of the CLI (chat, headless, subagents, the action) gets it instead of only CI.
Current behavior
- Approval is two-layer. Whether:
StandardApprovalPolicy.ShouldRequireApproval(internal/agent/approval_policy.go:39) - Auto-Accept / ReadOnly bypass everything; Bash is gated by the per-mode allow-list; other tools bytools.safety.require_approval. How:tools.safety.approval_behaviour=prompt|ipc|block(config/config.go:487-503), resolved byApprovalBehaviourForandResolveApprovalDelivery(behaviour, brokerAttached, isChatMode)(internal/agent/agent_event_driven.go:141-147). - Headless / CI with no approver reachable resolves to block: the agent cannot do anything off the allow-list. The only way to let it act is Auto-Accept, which removes the gate entirely.
internal/agent/states/approving_tools.go:115asksRequestToolApprovalper tool; a denial becomes a rejection tool-result viabuildRejectionEntry(:266) and the loop continues. This path already does everything a judge verdict needs.- No-tools one-shot LLM call template:
GenerateLLMSummary(internal/conversation/conversation_optimizer.go:290, directGenerateContent,SkipMCP: true, own timeout). Per-purpose model precedent:conversation.title_generation.modelfalling back toagent.model.
Proposed behavior
- New approval behaviour
judgenext toprompt|ipc|block: an approval-requiring tool call is decided by one LLM call instead of a human. It is always "reachable", so headless and CI get a real approver. - New mode
AgentModeAutoWithJudge(internal/agent/domain/values.go) as the preset that turns it on:ShouldRequireApprovalapplies the standard rules (AllowedlistKey()returns"standard", so allow-listed read-only commands still pass for free and anything off-list needs approval), and delivery is forced tojudge. Display nameAUTO+JUDGE; in the Shift+Tab cycle after Auto-Accept. Settingapproval_behaviour: judgeby hand in standard mode is also valid; the mode is the one-switch way and the only thing infer-action needs to pass. - Judge config in its own file like
hooks.yaml/reminders.yaml:
# .infer/judge.yaml
model: "" # defaults to agent.model (precedent: conversation.title_generation.model)
timeout: 30 # seconds per judge call
max_tokens: 256
on_error: deny # deny | allow when the judge times out or returns garbage
prompt: | # user-overridable; {intent} {action} placeholders
You are the approver for an autonomous coding agent. Given the user's
request, decide whether the pending tool call serves it and is safe to run.
Respond with exactly {"decision": "approved" | "rejected", "reason": "..."}.Every key has an INFER_JUDGE_* env override. No enabled key: the judge runs only when the mode (or approval_behaviour: judge) selects it.
-
Judge input, two parts, no transcript window or digest:
{intent}: the latest non-hiddenusermessage (the task in headless, the last human message in chat;hidden: truesystem reminders skipped).{action}: the tool call awaiting approval (name + arguments).
So
rm -rf build/is approved under "clean the build dir" and rejected under "fix the typo in README". -
Judge call: one
GenerateContentshaped likeGenerateLLMSummary(no tools,SkipMCP, bounded bytimeout/max_tokens). Defaulton_error: deny, because this is an approval gate and the existing no-approver behaviour is also block; a denied call carries the reason "judge unavailable" so the driver can retry or route around it. -
Verdict contract: the judge must answer with exactly one JSON object,
{"decision": "approved" | "rejected", "reason": "<short text>"}. The parser strips code fences and surrounding prose, requiresdecisionto be one of the two literals, and treats anything else as a judge error (->on_error). Parsed into aJudgeVerdict{Decision, Reason}domain value; nothing downstream reads the raw text. -
Verdict path:
rejectedreturns(false, nil)fromRequestToolApproval, sobuildRejectionEntryproduces the tool result with the judge'sreasonappended. No new state, no new state-machine edge. -
Chat feedback: a rejection surfaces in the TUI as a flash status message, "Action rejected by judge policy: ", via the existing
SetStatusEvent/StatusView.ShowStatusWithTypepath (internal/presentation/tui/keybinding/actions.go:414 flashStatus,components/status_view.go:84), fed by thejudge_verdictchat event. Headless gets the same text on stderr. -
Startup validation: selecting the mode (or
approval_behaviour: judge) with no judge model resolvable (judge.modelempty andagent.modelempty) fails fast at config validation with a clear error, before any gateway or agent starts. Same for an unparseablejudge.yaml. -
Observability: a
judge_verdictevent (tool,decision,reason,turn) on the--format jsonprotocol (internal/platform/render/render.go renderJSON, newagentdomain.ChatEvent) since CI consumers need it, mirrored on the hidden debug channel viastreamevent.EmitDebugEventlikecompaction_*. -
Headless mode selection: add
--modetoinfer headless(validated viaParseAgentMode) and honourINFER_AGENT_MODE. Today onlyINFER_SUBAGENT_AGENT_MODEreaches headless.
Implementation notes (code starting points)
config/config.go:ApprovalBehaviourJudge = "judge"; extendApprovalBehaviourFor,Validate,ResolveApprovalDelivery(judge is never downgraded to block for lack of a broker).config/judge.go(new, mirrorsconfig/hooks.go):JudgeConfig, defaults,LoadJudge,Validate(on_error in {deny, allow}). Wire incmd/runtime/config.gonext toLoadHooks, env overrides besideapplyHooksEnvOverrides;Config.Judgeasyaml:"-"likeConfig.Hooks.internal/agent/domain/hooks.go(orapproval_policy.go):JudgeVerdict{Decision, Reason}+ParseJudgeVerdict.internal/presentation/tui/app/chat.go: handle thejudge_verdictchat event ->SetStatusEventflash.internal/agent/domain/values.go: const,AllowedlistKey(->"standard"),ParseAgentMode,String,DisplayName.internal/agent/approval_policy.go: AutoWithJudge falls through to the standard rules (no bypass branch). Check the headless rule (doc comment item 3) so headless in this mode does require approval instead of relying onexecuteBash's own gate.internal/agent/agent.go requestToolApproval: when delivery resolves tojudge, build the intent + action input from the conversation repo and call a newJudgeApprover(port indomain/services.go, implementation next to the summariser ininternal/conversationor a newinternal/agent/judge.go).internal/agent/agent_event_driven.go:141 ApprovalDelivery: pass the mode so AutoWithJudge forcesjudge.- Mode fan-out (each needs the new value):
llm_tool_service.go ListToolsForMode,agent.go:1236 isAutoAcceptMode,presentation/tui/state.go CycleAgentMode,tui/components/mode_indicator.go,config/reminders.go defaultModeChangeGuidance(+ guidance-key validation),scheduler/domain/subagent.go InheritedAgentMode,tools/agent.go resolveSubagentType,conversation/tokenizer.go,browser/infrastructure/extension_bridge.go. cmd/headless/headless.go:--modeflag.- Rendering:
render.go renderJSONnew case +agui.go+RenderTextforjudge_verdict. - Tests:
approval_policy_test.go(mode uses standard rules),states/approving_tools_test.go(judge reject -> rejection entry with reason),config/judge_test.go,config/config_test.gofor the new behaviour value, anINFER_GATEWAY_MOCKscenario returning a canned verdict for e2e. - Docs:
docs/configuration-reference.md(approval_behaviour + judge.yaml),docs/shortcuts-guide.md, newdocs/judge-mode.md; a matching[DOCS]issue oninference-gateway/docswith the implementing PR.
Open design questions
on_errordefault: deny (proposed, consistent with block-when-no-approver) vs allow (never wedges a run). Config key covers both; only the default is in question.- Should the judge also veto the agent's final "done" message (a
post_streamcheckpoint that can force another turn)? Proposed out of scope for v1; the approval gate is the only checkpoint. - Granularity is one judge call per tool call needing approval (matches
processNextTool). A batch of 5 off-list Bash calls costs 5 judge calls. Acceptable for v1; batching is a follow-up. - Should
{intent}be the first user message of the session instead of the latest, or both? Proposed: latest only, since in chat the latest message is what the user wants now.
Acceptance Criteria
-
auto-with-judgeappears in the Shift+Tab cycle,ParseAgentMode,infer headless --mode auto-with-judgeandINFER_AGENT_MODE. -
tools.safety.approval_behaviour: judgevalidates and is never downgraded toblockfor lack of a broker. - Standard / plan / auto runs make zero judge calls (test asserts no extra
GenerateContent). - In the mode, an allow-listed Bash command executes with no judge call; an off-list command triggers exactly one judge call carrying the latest non-hidden user message and the pending tool call.
- The judge prompt requires, and the parser enforces, the JSON contract
{"decision": "approved" | "rejected", "reason": "..."};approvedexecutes the tool,rejectedyields the existing rejection tool-result with the judge's reason; any other output is a judge error. - On rejection the chat TUI shows a flash status message "Action rejected by judge policy: " (headless prints it to stderr).
- Starting
infer chat/infer headlessinauto-with-judge(or withapproval_behaviour: judge) with no judge model configured exits immediately with a clear config error, before the agent runs. - Judge timeout / error / unparseable output follows
on_error(default deny) with a warning and a distinguishable reason. - A
judge_verdictevent is emitted on--format jsonand mirrored on the debug channel. - Docs and configuration reference updated;
judge.yamldocumented next tohooks.yaml/reminders.yaml.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
edenreich commentedon Sep 2, 2026
@infer Can you implement this? use /ponytail:ponytail /go /go-concurrency /cobra-viper /lipgloss-v2 /bubbles-v2 /bubbletea-v2
inference-gateway-maintainer commentedon Sep 2, 2026
Model:
ollama_cloud/glm-5.3-flash· View JobTodos
Pull Request
#1148
The agent reached its turn limit before finishing. Its work was pushed; the pull request linked above carries the remaining todos - review it and pick up where the agent left off, or re-trigger to continue.
The approval policy test has a clean table pattern. Let me check the YAML util signature and the test runner section before writing tests.
Model:
ollama_cloud/glm-5.3-flash· Exit Code:2· Duration: 23m 13sTokens: 19,250,499 in · 85,535 out · 19,336,034 total (148 requests)
Tool calls: 256 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
feat(agent): add auto-with-judge mode with an LLM judge as the tool a…
inference-gateway-releaser commentedon Sep 2, 2026
🎉 This issue has been resolved in version 0.188.0 🎉
The release is available on:
Your semantic-release bot 📦🚀