Tool-using LLM agents are increasingly used to automate workflows governed by procedural manuals, such as company rules for booking travel or procuring hardware. These manuals are written in natural language for humans and describe general requirements over such complex workflows. Ensuring compliance of LLM agents with these manuals is difficult, and state-of-the-art techniques use either LLM judges or manually written rules to forbid problematic tool-calls locally at runtime. This is insufficient because (i) only blocking tool calls keeps the agent clueless about how to make correct progress towards fulfilling its task, and (ii) can lead to overly conservative behavior of the agent, as tool calls might only be problematic in certain contexts. To overcome these challenges, we introduce MENTOR, which (i) additionally provides guidance for the agent to make procedural-compliant progress on the task, and (ii) ensures that this compliance is context-aware. We achieve these goals by building a novel history-dependent runtime shield that is obtained from the procedural manual via a multi-step autoformalization pipeline. At its core, MENTOR utilizes a game-based technique to ensure robustness against runtime uncertainty without over-resticting agents' behavior. This yields a formally assisted framework for procedural shielding of LLM agents that improves compliance well beyond existing methods. In particular, MENTOR lifts the compliance of shielded light-weight open-source LLMs above that of non-shielded proprietary models. Since a shield is synthesized once per manual and then serves every task, a MENTOR-shielded agent becomes a viable choice for repeatedly executed workflows, potentially reducing deployment costs when the offline construction cost is amortized over repeated tasks.
Figures & tables
Figure 1: Running example. Our procedural shield MENTOR is generated from a procedural manual (top right) and applied to a travel-booking task (top left). MENTOR shields the interaction between an LLM agent (pink) and the environment (brown). MENTOR blocks tool calls (red), allows tool calls (green), and provides guidance towards task completion (orange).
Figure 2: Overview of MENTOR . Manual and tool schema are formalized into an LTL-based template and an SMT-based solver (offline, top right), used to shield every tool call (online, left) by deterministically evaluating (bottom right) if tool calls are safe and progressing (violet, LTL), and use correct arguments (blue, SMT); unsafe and non-progressing calls receive advice (orange).
Figure 3: Autoformalization.
Figure 4: Game graph and template (excerpt) for the example from Fig. 1 .
(a) MANTRA
Operations ( N=47 )
Sneaky Sasquatch ( N=43 )
τ2 -retail ( N=57 )
τ2 -airline ( N=44 )
Guard
L3.1
Q3
Q3.6
G4
L3.1
Q3
Q3.6
G4
L3.1
Q3
Q3.6
G4
L3.1
Q3
Q3.6
G4
None
0 6 ± 4
45 ± 7
60 ± 7
51 ± 7
21 ± 6
33 ± 7
53 ± 8
23 ± 7
0 5 ± 3
11 ± 4
21 ± 5
16 ± 5
20 ± 6
36 ± 7
52 ± 8
34 ± 7
AgentSpec
13 ± 5
55 ± 7
72 ± 7
62 ± 7
14 ± 5
28 ± 7
63 ± 7
16 ± 6
0 9 ± 4
25 ± 6
26 ± 6
19 ± 5
30 ± 7
43 ± 8
50 ± 8
43 ± 8
Progent
0 4 ± 3
47 ± 7
68 ± 7
47 ± 7
21 ± 6
30 ± 7
51 ± 8
23 ± 7
0 9 ± 4
12 ± 4
25 ± 6
21 ± 5
27 ± 7
39 ± 7
45 ± 8
39 ± 7
DynaGuard
11 ± 5
21 ± 6
40 ± 7
28 ± 7
19 ± 6
30 ± 7
49 ± 8
19 ± 6
12 ± 4
23 ± 6
19 ± 5
19 ± 5
34 ± 7
34 ± 7
39 ± 7
27 ± 7
[][] Ours (prompt)
36 ± 7
72 ± 7
66 ± 7
72 ± 7
35 ± 7
63 ± 7
70 ± 7
65 ± 7
16 ± 5
33 ± 6
33 ± 6
40 ± 7
41 ± 7
64 ± 7
64 ± 7
50 ± 8
Table 1: Pass^5± standard error (%) over the N test cases of a domain. (a) Open-weights agents on MANTRA against the baselines. (b) Proprietary agents on MANTRA domains. (c) Open-weights agents on AgentOrca . None denotes no shield, and the highest value in each column is bolded.
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
Table 2: Comparison of MENTOR with existing LLM guarding approaches: supported, partially supported, not supported, – not applicable.
Figure 6: Abstract structure and syntax of the specification language. Braces denote finite collections. In (a), S is an entity type and κ its entity-identification rules; kind classifies a temporal requirement as a safety requirement or an obligation, and m is its source sentence. A request declaration gives a pseudo tool name Q , a typed argument schema Σ , defaults d , and extraction instructions I . An observation declaration identifies the free-text and label fields of an outcome and its label vocabulary Λ . In (c), c is a constant, π a field path, and bv the event introducing the entity. The function meanings are given in Table 3 . Auxiliary string, list, and conversion helpers are omitted from the core expression grammar.
Expression
Meaning
last(p(v))
The latest earlier event satisfying p(v) ; if none exists, its fields are undefined ( null ).
exists(p(v)) , count(p(v))
Whether an earlier event satisfies p(v) , and the number of such events, respectively.
hist(p(v),π)
The non-null values at path π from earlier events satisfying p(v) , in chronological order.
present(e)
Whether e is neither null, an empty string, nor an empty list.
len(e)
The length of a string or list; zero for an unsuitable value.
contains(e1,e2)
For a list e1 , whether it contains an element equal to e2 ; for a string, a case-insensitive substring test.
Appendix
Table 3: Functions in the core expression language. History operations use earlier recorded events with the entity parameter v bound. A field path π selects information from an event’s tool arguments or outcome.
Domain
Model
None
AgentSpec
Progent
DynaGuard
Ours
Ours
(prompt)
(token)
Llama 3.1
0.26 ± 0.05
0.34 ± 0.06
0.27 ± 0.05
0.20 ± 0.05
0.61 ± 0.06
0.58 ± 0.06
Qwen3
0.62 ± 0.06
0.71 ± 0.06
0.66 ± 0.06
0.34 ± 0.06
0.80 ± 0.05
0.70 ± 0.06
Qwen3.6
0.72 ± 0.06
0.84 ± 0.05
0.75 ± 0.06
0.51 ± 0.07
0.79 ± 0.05
0.74 ± 0.06
Gemma 4
0.63 ± 0.07
0.69 ± 0.06
0.65 ± 0.06
0.39 ± 0.07
0.84 ± 0.05
0.73 ± 0.06
GPT-5.4 mini
0.72 ± 0.06
–
–
–
0.82 ± 0.05
–
Appendix
Table 4: Pass@ 1 on the four MANTRA domains for open-weight (white) and proprietary (gray) agents.
Domain
Model
None
AgentSpec
Progent
DynaGuard
Ours
Ours
(prompt)
(token)
Llama 3.1
0.43 ± 0.07
0.60 ± 0.07
0.47 ± 0.07
0.32 ± 0.07
0.77 ± 0.06
0.81 ± 0.06
Qwen3
0.72 ± 0.07
0.81 ± 0.06
0.79 ± 0.06
0.47 ± 0.07
0.85 ± 0.05
0.77 ± 0.06
Qwen3.6
0.79 ± 0.06
0.89 ± 0.05
0.81 ± 0.06
0.64 ± 0.07
0.85 ± 0.05
0.85 ± 0.05
Gemma 4
0.70 ± 0.07
0.74 ± 0.06
0.79 ± 0.06
0.49 ± 0.07
0.87 ± 0.05
0.83 ± 0.06
GPT-5.4 mini
0.81 ± 0.06
–
–
–
0.85 ± 0.05
–
Appendix
Table 5: Pass@ 5 on the four MANTRA domains for open-weight (white) and proprietary (gray) agents.
TSR
Domain
Model
None
Ours
Ours
(prompt)
(token)
Patient intake ( N=35 )
Llama 3.1
0.03 ± 0.05
0.29 ± 0.28
0.38 ± 0.20
Qwen3
0.29 ± 0.11
0.61 ± 0.04
0.46 ± 0.07
Qwen3.6
0.90 ± 0.07
1.00 ± 0.00
1.00 ± 0.00
Gemma 4
1.00 ± 0.00
1.00 ± 0.00
1.00 ± 0.00
Appendix
Table 6: Task Success Rate (TSR), SOP-Bench’s flawed benchmark score, of open-weights agents on two domains.
Domain
Model
Claude Opus 5
Claude Sonnet
gpt-5.5
gpt-5.6-luna
Qwen3.8
Operations ( N=47 )
Llama 3.1
0.38 ± 0.06
0.09 ± 0.04
0.47 ± 0.07
0.13 ± 0.05
0.11 ± 0.05
Qwen3
0.64 ± 0.07
0.34 ± 0.07
0.68 ± 0.07
0.23 ± 0.06
0.34 ± 0.07
Gemma 4
0.75 ± 0.06
0.68 ± 0.07
0.79 ± 0.06
0.36 ± 0.07
0.55 ± 0.07
τ2 -retail ( N=57 )
Llama 3.1
0.28 ± 0.05
0.25 ± 0.06
0.09 ± 0.04
0.16 ± 0.05
0.14 ± 0.05
Qwen3
0.39 ± 0.06
0.46 ± 0.07
0.39 ± 0.07
0.28 ± 0.06
0.42 ± 0.07
Gemma 4
0.33 ± 0.06
0.32 ± 0.06
0.35 ± 0.06
0.30 ± 0.06
0.35 ± 0.06
Appendix
Table 7: Pass^3 of the prompt shield on two MANTRA domains and three agents, with the specification written by different models.
Domain
Model
None
AgentSpec (LLM-gen)
AgentSpec (our loop)
Ours
Operations ( N=43 )
Llama 3.1
0.00 ± 0.00
0.05 ± 0.03
0.00 ± 0.00
0.26 ± 0.07
Qwen3
0.28 ± 0.07
0.26 ± 0.07
0.19 ± 0.06
0.58 ± 0.08
Qwen3.6
0.60 ± 0.08
0.77 ± 0.07
0.77 ± 0.07
0.70 ± 0.07
Gemma 4
0.56 ± 0.08
0.63 ± 0.07
0.56 ± 0.08
0.70 ± 0.07
Sneaky Sasquatch ( N=39 )
Llama 3.1
0.08 ± 0.04
0.03 ± 0.03
0.00 ± 0.00
0.15 ± 0.06
Qwen3
0.44 ± 0.08
0.23 ± 0.07
0.41 ± 0.08
0.69 ± 0.07
Appendix
Table 8: Pass^5± standard error over the N held-out cases of a domain, for the prompt shield with AgentSpec rules written by AgentSpec ’s LLM rule generator (LLM-gen) and by our autoformalization loop (our loop), next to the unshielded agent (None) and our specification (Ours).
Pass^3
Sneaky Sasquatch
τ2 -retail
Labeler
Qwen3
Gemma 4
Qwen3
Gemma 4
gpt-4.1-mini
0.70 ± 0.07
0.62 ± 0.07
0.39 ± 0.06
0.33 ± 0.06
Qwen3-4B
0.68 ± 0.07
0.60 ± 0.07
0.44 ± 0.06
0.28 ± 0.05
Gemma 4
0.07 ± 0.04
0.07 ± 0.04
0.42 ± 0.07
0.28 ± 0.06
gpt-oss
0.02 ± 0.02
0.07 ± 0.04
0.35 ± 0.06
0.26 ± 0.06
Appendix
Table 9: Labeler ablation: Pass^3 of the prompt shield on two MANTRA domains and two agents.
Prompt shield
Prompt shield
Token shield
(gpt-4.1-mini)
(gpt-4.1)
(gpt-4.1)
Domain
Model
Pass^k 5
Pass^k 5
Pass^k 5
Operations
Llama 3.1
0.28 ± 0.07
0.21 ± 0.06
0.38 ± 0.07
Qwen3
0.62 ± 0.07
0.64 ± 0.07
0.55 ± 0.07
Qwen3.6
0.72 ± 0.07
0.70 ± 0.07
0.66 ± 0.07
Gemma 4
0.72 ± 0.07
0.77 ± 0.06
0.57 ± 0.07
Appendix
Table 10: Labeler ablation: Pass^5 on all MANTRA with the GPT-4.1 mini and the GPT-4.1 labeler.
Pass^5
Domain
Model
None
Ours (gpt-4.1)
Ours (Qwen3-4B FT)
Operations ( N=47 )
Llama 3.1
0.00 ± 0.00
0.21 ± 0.06
0.30 ± 0.07
Qwen3
0.28 ± 0.07
0.64 ± 0.07
0.60 ± 0.07
Qwen3.6
0.62 ± 0.07
0.72 ± 0.07
0.72 ± 0.07
Gemma 4
0.55 ± 0.07
0.77 ± 0.06
0.70 ± 0.07
Sneaky Sasquatch ( N=43 )
Llama 3.1
0.07 ± 0.04
0.09 ± 0.04
0.14 ± 0.05
Appendix
Table 11: Pass^5± standard error over the N test cases of a domain, on the MANTRA synthetic domains (top) and the MANTRA τ2 domains (bottom), without a shield (None) and with our prompt shield, with gpt-4.1 or the fine-tuned Qwen3-4B as the labeler.
Domain
Model
None
AgentSpec
Progent
DynaGuard
Ours (prompt)
Ours (token)
Operations ( N=47 )
Llama 3.1
0.59 ± 0.03
0.57 ± 0.02
30.70 ± 0.46
3.01 ± 0.07
0.73 ± 0.04
2.26 ± 0.05
Qwen3
10.00 ± 0.67
9.95 ± 0.13
44.31 ± 1.29
13.28 ± 0.20
9.58 ± 0.55
10.52 ± 0.18
Qwen3.6
18.96 ± 0.82
25.72 ± 2.31
54.21 ± 1.85
65.25 ± 5.64
29.12 ± 2.98
23.87 ± 2.90
Gemma 4
0.64 ± 0.01
0.64 ± 0.01
34.47 ± 0.92
2.63 ± 0.06
0.75 ± 0.03
0.99 ± 0.03
Sneaky Sasquatch ( N=43 )
Llama 3.1
0.39 ± 0.01
0.40 ± 0.01
21.25 ± 0.98
2.34 ± 0.14
0.45 ± 0.00
1.66 ± 0.04
Qwen3
7.52 ± 0.69
8.89 ± 0.28
28.77 ± 1.08
10.68 ± 0.79
6.72 ± 0.22
10.57 ± 1.47
Appendix
Table 12: Seconds per proposed tool call (including blocked), mean ± standard deviation.
Domain
Model
None
AgentSpec
Progent
DynaGuard
Ours (prompt)
Ours (token)
Operations ( N=47 )
Llama 3.1
4.8 ± 0.1
7.4 ± 0.3
5.0 ± 0.2
18.1 ± 1.1
8.7 ± 0.5
11.0 ± 0.3
Qwen3
4.3 ± 0.1
4.9 ± 0.2
4.4 ± 0.1
13.3 ± 0.9
5.3 ± 0.1
8.3 ± 0.9
Qwen3.6
5.0 ± 0.1
5.3 ± 0.2
5.1 ± 0.3
9.0 ± 0.8
6.3 ± 0.3
10.9 ± 0.4
Gemma 4
5.2 ± 0.1
5.2 ± 0.0
5.1 ± 0.1
5.3 ± 0.2
6.1 ± 0.6
10.5 ± 1.0
Sneaky Sasquatch ( N=43 )
Llama 3.1
8.6 ± 1.5
11.8 ± 1.1
8.7 ± 1.1
10.8 ± 1.1
9.0 ± 0.3
8.8 ± 0.6
Qwen3
4.2 ± 0.2
5.6 ± 0.3
4.5 ± 0.2
6.1 ± 0.6
5.6 ± 0.1
6.5 ± 0.3
Appendix
Table 13: Number of tool calls the agent proposed per testcase (including blocked) mean ± standard deviation.
GPT-4.1 mini
GPT-4.1
Domain
cases
cents/case
USD/domain
cents/case
USD/domain
Operations
47
0.06
0.029
0.30
0.143
Sneaky Sasquatch
43
0.07
0.030
0.35
0.150
τ2 -retail
57
0.25
0.141
1.24
0.705
τ2 -airline
44
0.20
0.086
0.97
0.429
Appendix
Table 14: Cost of the labeler per domain, in US cents per testcase and in USD per one run over the full domain, at prices of GPT-4.1 mini (0.40/1.60 USD per 1M input/output tokens) and GPT-4.1 (2.00/8.00).
Tool-using large language model (LLM) agents are increasingly deployed in settings where their reliable behavior is governed by strict procedural manuals. Ensuring that such agents comply with the rules from these manuals is challenging, as they are typically written for humans in natural language while agent behavior manifests as an execution trace of tool calls. Existing evaluations of LLM agents rely on manually constructed benchmarks or LLM-based judges, which either do not scale or lack reliability for complex, long-horizon manuals. To overcome these limitations, we present MANTRA, a framework for automatically synthesizing machine-checkable compliance benchmarks from natural-language manuals and tool schemas. MANTRA independently generates (i) a symbolic world model capturing procedural dependencies, and (ii) a set of trace-level compliance checks for a given task, and validates their consistency using SMT solving. A structured repair loop resolves inconsistencies, requiring human intervention only as a fallback. %This yields benchmarks that are formally validated. Importantly, MANTRA supports arbitrary domains and long procedural manuals, and provides a tunable notion of task complexity which is utilized to automatically derive challenging tasks accompanying compliance checks. Using MANTRA, we build a new benchmark suite with 285 tasks across 6 domains scaling to 50+ page manuals with minimal human effort. Empirically, we show that the compliance checks are richer with stronger constraint enforcement compared to existing benchmarks. Additionally, the granularity of the checks can be used for debugging the agents' failure modes. These results demonstrate that combining automated benchmark generation with formally grounded validation methods enables scalable and reliable benchmarking of tool-using agents.
Ashwani Anand, Ivi Chatzi, Ritam Raha +1
Max Planck Institute for Software Systems, Kaiserslautern, Germany
Tool-using LLM agents are usually evaluated by final-answer correctness or LLM judges. Neither captures how an answer was produced. In safety-critical settings, the procedure itself is part of correctness. In this paper, we introduce AgentLTL, a language derived from First-Order Linear Temporal Logic (FO-LTL) that expresses procedural rules over agent traces. It yields a deterministic, judge-free compliance score. In this framework, a single specification drives two usages. The first is harnessing: the constraints score completed traces, or gate tool calls by checking each prefix online, before execution. The second is finetuning: the score serves as a dense reward. On a benchmark spanning ordering, branching, iteration, and grounding, block-and-warn harnessing improves compliance on five of seven models. Finetuning with the same reward yields +38 and +17.5 percentage point gains in accuracy and compliance on held-out patterns, including unseen tool-name aliases. These findings are consistent with the model acquiring procedural structure rather than memorizing surface tool names and procedures.
Enterprise agents must follow long-horizon, conditional, safety-critical standard operating procedures (SOPs). We compile machine-readable SOP constraints into executable pseudo-code and run them with a program-guided (PG) stack machine that pages the active frame while an LLM performs semantic execution. A three-arm SOPBench study across six models separates representation from runtime: compiled text never significantly hurts and gains up to 16.0 points where official prose underperforms. Runtime guidance is capability-gated. Two strong models independently show positive seven-domain PG contrasts (58:19 and 75:31 discordant pairs), whereas weak models are harmed. A full-program cursor ablation (active frame first, complete program retained) recovers much of the strong-model refusal gain; selective visibility adds a smaller improvement. Paired probe and audit measurements track this divide to spontaneous state discipline rather than reconstruction ability. On Bank the three primary arms rise from 70.4 to 86.4 to 92.8, with 100% refusal correctness. Practical guidance: compile first; enable active-frame paging only after a model-level discipline check.
Chenglin Yu, Li Yin, Ying Yu +4
Department of Industrial and Systems Engineering, The Hong Kong Polytechnic University · Department of Data and Systems Engineering, The University of Hong Kong · College of Economics and Management, Zhejiang Normal University +3