Without VeriTool
RLM with direct tool access
Plans, reasons, and decides when to call tools.
Broad capability surface, difficult to reason about, easy to misuse.
Unsafe reads, unsafe writes, unsafe queries, unsafe outbound calls.
Secure Program Synthesis / Vericoding
VeriTool is a counterexample-guided synthesis pipeline for building narrowly scoped agent tools with explicit safety invariants. Instead of asking whether a model is aligned, we ask whether each capability it receives is constrained, inspectable, and verifier-approved.
Core Idea
Recursive language models and autonomous coding agents become dangerous when they inherit broad REPL access to the filesystem, network, databases, and arbitrary computation. VeriTool inverts the framing: rather than proving the agent's reasoning is safe, it synthesizes the environment interfaces the agent can use and rejects unsafe tool implementations with concrete counterexamples.
The loop is deliberately simple and legible: write a formal safety invariant, generate a candidate tool with the LLM, verify it under bounded checks and policy guards, then feed the counterexample back into the next iteration.
Where VeriTool Fits
The key intervention is not inside the model weights. VeriTool sits between the RLM and the external capabilities it wants to use, turning raw tool access into a constrained synthesis-and-verification gate.
Without VeriTool
Plans, reasons, and decides when to call tools.
Broad capability surface, difficult to reason about, easy to misuse.
Unsafe reads, unsafe writes, unsafe queries, unsafe outbound calls.
With VeriTool
Requests a capability instead of getting unconstrained tool access.
Synthesizes a narrow tool and admits it only if the invariant holds under bounded checks.
The RLM can still act, but only through approved tools with explicit safety invariants.
Vericoding Loop
Write a narrow tool contract and formal invariant.
Prompt the LLM to produce candidate Python code for the tool.
Run AST guards, policy checks, and bounded executable verifiers.
Inject the concrete counterexample into the next generation step.
Completed Runs
This view summarizes the completed live runs for `claude-sonnet-4`, `gpt-4o`, `deepseek-v3.2-exp`, and `gemini-2.5-pro`. Every model was evaluated on the same six-tool suite with the same four-iteration budget per tool.
How to read pass / fail
Each tool gets at most 4 generation attempts. After every attempt, VeriTool runs the verifier. A tool is marked pass if any candidate satisfies the full safety and behavioral spec within that budget. It is marked fail if no verifier-approved candidate is found before the 4-call limit is exhausted.
The aggregate view makes the comparison legible: some models converge reliably on most tool families, while others burn through the budget on verifier violations or fail to repair the right counterexample in time.
Best completed run so far, finishing with five verified tools in 17 total iterations.
Middle of the pack: four verified tools, with failures concentrated in API safety and bounded evaluation.
Also reached four verified tools, but with a different profile: it solved API calling and bounded evaluation.
Completed, but converged on only two tools before exhausting the verifier budget on the rest.
What the benchmark reveals
The easy lanes are bounded logging, local file reads, and small SQL fragments once the model internalizes the guardrail. The hard lanes are outbound API policy enforcement and tiny arithmetic evaluators, where small structural mistakes keep triggering the verifier.
Long-Term Vision
An agent encounters a new API, schema, or file format and proposes a tool it wishes it had.
The system applies universal rules like no arbitrary network calls, no raw disk writes, and no unsafe escalation.
The CEGIS loop synthesizes and rejects candidates until it finds a bounded-safe interface.
Only the verified tool is injected back into the agent environment for immediate use.
The destination is not a static “safe tool belt.” It is a runtime compiler for agent capabilities that expands what the system can do without relaxing the environment boundaries that keep it safe.
Limits and Honesty
VeriTool is not a universal proof system for arbitrary Python. The current evidence is bounded and tool-specific, combining AST restrictions, policy checks, regex guards, and executable reference oracles.
The completed runs span outcomes from 2 of 6 to 5 of 6 tools. That spread is the useful result: the mechanism is strong enough to expose real differences in repair behavior, but still narrow enough that failures remain concrete and diagnosable.