arXiv:2610.28989cs.AIOct 2026

Manuscript Offprint

arXiv:2610.28989

AgentPolicyForge: From Executable Environments to Policy Benchmarks and Adaptive Guards

Chao Shang, Wanyu Du, Yi Zhang, Sandesh Swamy

Abstract

Customized agent deployments define policies over tools, resources, and execution conditions. Providing these policies in the task agent's prompt does not reliably prevent violations. Training a guard requires examples of tool calls that comply with or violate those policies. We introduce AgentPolicyForge, a framework that uses executable environments to construct policy benchmarks and iteratively train policy guards. With this framework, we construct PolicyGym, a dataset across ten policy families using 698 scenarios for training data generation and 254 separate held-out scenarios for human-reviewed test sets. Tool calls are executed and their outcomes recorded to help determine whether they comply with the policy. Every violating case uses a permitted tool, requiring checks of arguments, resources, and context rather than tool identity alone. The case construction process supports iterative guard training: an attacker generates requests using retrieved strategies, and the guard is fine-tuned on balanced, environment-verified examples. Training improves policy enforcement even with a fixed archive. Updating the archive further reduces in-domain attack success compared with keeping it fixed. We compare policy-aware task agent self-regulation with a trained policy guard. On PolicyGym, the final guard-based configuration achieves a 40–44% relative reduction in attack success rate and fewer benign rejections than policy prompting alone.

1 Introduction

Language-model agents increasingly call tools, query databases, and modify external systems (Schick et al., 2023; Yao et al., 2023; Xi et al., 2025). Deployments govern these actions through policies specifying which tools and resources agents may use and under what conditions (Wen et al., 2026a; VIOLA, 2026). For example, a transfer tool may be permitted only for amounts below a limit, and record access may be restricted to the record's owner. An allowed tool can therefore still be used in violation of policy: compliance depends on its arguments, the resources it accesses, and the state in which it executes.

Providing the policy directly to the task agent reduces violations, but leaves substantial enforcement errors. In our evaluation, a policy-prompted frontier agent still allows violating calls to execute in 13–15% of threat episodes and rejects around 9% of benign requests ( §4.2§4.2). A separate guard allows policy enforcement to be trained and evaluated independently of the task agent, without changing the task agent's weights. To train and evaluate this guard, we need tool calls paired with policies, relevant context, and compliance labels.

These examples must cover both compliant and violating calls, with labels grounded in what the agent actually proposes. A request alone is insufficient: the agent may propose a different action, and successful execution does not establish policy compliance. Executable environments let us reset state, execute concrete calls, and inspect their outcomes, linking policy judgments to observable evidence. Training data can then be refreshed to target remaining misses and false alarms, while held-out tests stay fixed to measure progress.

Existing policy benchmarks and monitors provide resources for evaluating deployment-specific compliance, including PolicyGuard (Wen et al., 2026a) and VIOLA (VIOLA, 2026). Our focus is constructing new policy cases from executable environments: binding rules to concrete tools and state, collecting calls and execution evidence, and reusing this process for both fixed tests and fresh guard training data.

We introduce AgentPolicyForge, a framework that uses executable environments to construct policy benchmarks and iteratively train policy guards through a shared case-construction process. A shared construction process generates requests targeting compliance or violation, collects calls from a policy-blind task agent, and executes them to collect evidence for determining whether the calls comply with the policy. Environment adapters provide access to tools, state, and execution. The framework then binds policy rules and executable checks to each scenario’s tools and state.

With this framework, we construct PolicyGym, a dataset for training and evaluating policy guards across ten policy families. Training data generation uses 698 Agent World Model (AWM) scenarios (Wang et al., 2026). Human-reviewed tests use 254 separate held-out scenarios: 187 in-domain (ID) and 67 out-of-domain (OOD) within AWM. OOD scenarios come from groups not used for training data generation, but remain within AWM. Each example pairs a proposed tool call with policy rules, relevant context, execution evidence, and a compliance label. Every violating test case uses a permitted tool but breaches an argument, resource, or context condition, which shows that identifying forbidden tools alone is insufficient.

We use PolicyGym’s training seeds and the construction process to generate fresh examples for iterative guard training. Each round, an attacker retrieves archived strategies to generate fresh requests. We fine-tune the policy guard using supervised fine-tuning (SFT) on a balanced set of verifier-confirmed violations and compliant calls, including violations it missed and compliant calls it incorrectly blocked. Training with a fixed archive already reduces ASR on both evaluation splits. We also update the archive with candidate strategies derived from attack outcomes. Candidates are validated on training scenarios before entering the archive. This archive-mediated coevolution links guard updates through SFT to strategy updates that guide subsequent requests.

After ten rounds of coevolutionary training, the guard achieves attack success rates (ASR) of 8.22% in-domain and 7.89% out-of-domain when filtering fixed task-agent proposals. Compared with policy-aware task-agent self-regulation, this configuration achieves a 40–44% relative reduction in ASR and rejects fewer benign requests. We compare fixed and evolving archives after ten matched training rounds. Updating the archive lowers in-domain ASR by 24.1% but increases benign over-block by 0.75 percentage points.

• We introduce AgentPolicyForge, a framework that constructs policy benchmarks and trains policy guards in executable environments. It binds deployment policies to concrete tool calls, uses execution evidence to check generated cases, and produces separate cases for held-out evaluation and iterative guard training.

• We contribute PolicyGym, an execution-grounded policy-compliance dataset with supervision generated from 698 scenarios and human-reviewed tests on 254 separate held-out scenarios. Every violating test case uses a permitted tool, requiring guards to check policy conditions on arguments, resources, and context rather than identify forbidden tools.

• We develop an iterative guard-training process that generates fresh compliant and violating cases for SFT. Training reduces ASR on both evaluation splits with a fixed strategy archive. Archive-mediated coevolution further uses guard feedback to update attack strategies, with an additional in-domain blocking gain in the matched run.

References (59)