arXiv:2610.31376cs.AIOct 2026

Manuscript Offprint

arXiv:2610.31376

Certified Execution Harness for Agentic AI: Safe and Least-Intrusive Petri-Net Supervisory Control Between Reasoning and Action

Chao Gu, Quanyan Zhu

Chao Gu 1^{1} and Quanyan Zhu 2^{2}

Abstract—This paper studies the problem of safe tool execution for large language model (LLM) agents under prompt injection. Using Petri nets, we formalize the execution harness between the LLM and its tools as a supervisory control problem, in which marks represent capabilities, approvals and budgets. Since a transition fires only if the marks it needs are present, an injected request whose preconditions are unmet or already spent is refused regardless of its wording. Treating tool outcomes as uncontrollable, we enforce safety by the conventional maximally permissive supervisor, and this safety transfers to the running system under four assumptions. Moreover, to capture an agent that may propose again after a refusal, we introduce the notion of a replanning closed loop, in which each retry costs an inference call. We show that, in this loop, the conventional supervisor can be arbitrarily more intrusive than a stricter safe one. Furthermore, for a given proposer model, the maximally permissive least-intrusive supervisor is characterized as a value-threshold refinement of the conventional one. Under precise conditions, this refinement orders two concurrent actions by at most one monitor place. On an autonomous release agent, we find by synthesis that safe deployment requires a step that the supervisor can refuse after a rollout starts.

I. INTRODUCTION

Agentic AI systems use large language models (LLMs) to plan, call tools and exchange messages with other agents and with humans. Unlike an LLM that only writes text, an agent that calls tools can deploy a release, delete a file, leak a credential or spend a budget that cannot be recovered. Consider a release agent that plans a patch, runs tests and a security scan, obtains a human approval and deploys. Suppose that an instruction hidden in the issue description asks the agent to deploy immediately. Without an external check, the decision to deploy then relies solely on the LLM, which is the component that the injected instruction is designed to manipulate. If the LLM follows the instruction, the release goes live and cannot be undone. Such a premature deployment is an example of an operational failure, in which an action occurs out of order or more often than allowed. Other examples are an approval used twice and two agents holding one lock. In the latter case, both agents use a resource that only one may use at a time, such as a file or a deployment slot. In this paper, we address such operational failures. A credential leak, for example, is covered if it requires an action that the workflow does not permit at that point, but not if a permitted call carries the secret in its arguments.

Execution Harness (trusted)

Figure

Fig. 1. The execution harness between the untrusted LLM and its tools. The LLM proposes a tool call uku_k, which is executed (green path) if and only if checks i)-iv) of the admission rule Eq. (1) pass. Otherwise, the LLM may propose again at the cost of an inference call. Admitted firings and uncontrollable firings (of transitions in TuT_u) update the marking MkM_k, i.e., the operational state. Assumption A4(a) in Section IV-D excludes the bypass (red dashed arrow), in which the untrusted LLM acts on the environment directly and skips the admission rule.

Four common defenses have been used to protect LLM agents. First, a policy in the system prompt is text in the same context window that the attacker writes into. A rule such as “never deploy without approval” is thus only a request to the LLM. Second, a guardrail classifier asks a question about content, namely whether a message looks malicious. Third, access control decides who may act at all, and a permission, once granted, can usually be reused. Finally, sandboxing, which we take as a prerequisite, limits the damage that an action can cause. While these defenses are useful, none of them keeps track of the operational state, namely which actions have already occurred and what they have consumed. Stateful runtime enforcers, which are programs that check each action while the agent runs, do track such state, as do schemes that consume authorizations [1]. Nevertheless, they apply specified rules or a learned model [2]–[7] and do not use a supervisor synthesized to stay safe under uncontrollable outcomes. These are outcomes that cannot be refused, such as tool results and human decisions.

To decide whether an action may occur now, given what has already been spent, we start from the software around an LLM, which is called its harness or scaffold in agentic-AI practice [8]. This software executes the tool calls that the LLM proposes. Within it, we define a formal execution harness as the part that admits or refuses each proposed tool call. This execution harness makes such decisions without asking whether any content looks malicious. As shown in Fig. 1, the LLM proposes a tool call, and an interface maps the proposal to a transition of a Petri net, which keeps track

1^{1}C. Gu is with the School of Electronics, Electrical Engineering and Computer Science, Queen's University Belfast, Belfast, UK cgu@qub.ac.uk; chaogu.ac@gmail.com

2^{2}Q. Zhu is with the Department of Electrical and Computer Engineering, New York University, Brooklyn, NY 11201, USA qz494@nyu.edu of the operational state. The net then decides whether this transition is enabled, while a supervisor, synthesized to stay safe under uncontrollable outcomes, decides whether it is permitted. The tool call will be executed only if, in addition, a validator accepts its arguments.

We adopt Petri nets to represent the operational state, since this state consists of resources that the actions of an agent produce and consume. For instance, an approval authorizes one deployment, and a tool call consumes one unit of budget. A Petri net represents such resources as marks* in places and actions as transitions. The distribution of marks over the places, called the marking, is then the operational state. In this way, workflow rules become the structure of the net, while a policy in the system prompt states them only as instructions to the LLM. For example, the counting rule “the number of deployments never exceeds the number of approvals” becomes a linear inequality on firing counts. This inequality is enforced by one extra place that holds the unspent approvals, called a monitor place [9]–[11]. The monitor place does so for any number of approvals and without enumerating states, but a finite automaton needs a bound fixed in advance.

However, safety alone does not determine the design of the supervisor. In the conventional supervisory control of discrete-event systems, a disabled event does not occur, but an LLM agent receives a refusal as an error, and it may propose again [12]. Each such retry costs an inference call. Even when the supervisor keeps an injected instruction from causing an unsafe action, the instruction may still lead the agent to propose actions that are refused. In view of this, besides which actions the agent may take, it is also important to ask how much the supervisor hinders the agent, which we call the intrusiveness of the supervisor. Specifically, in this paper we count intrusiveness in refusals or in inference calls, and thus study which safe nonblocking supervisors hinder the agent least. Here, a supervisor is said to be nonblocking if a run under it can always be finished. Our contributions are threefold, as outlined below.

First, we formalize the execution harness as a supervisory control problem on the agentic execution Petri net (AEPN). In the AEPN, an admission rule fixes what the LLM may influence. Moreover, with consumable authorization, each approval or budget is a mark that a firing spends, so that rules against replay, reuse and out-of-order actions become linear inequalities. Safety is then enforced by a supervisor computed with the conventional Ramadge–Wonham supervisory control [13], [14]. We also propose four assumptions under which this safety transfers to the running system. Specifically, these assumptions require that the net tracks the running system faithfully and that no action or event bypasses the execution harness.

Second, as the main technical contribution, we introduce the replanning closed loop, in which the agent may propose again after a refusal, at a cost. We show that in this loop, the conventional maximally permissive supervisor can be arbitrarily more intrusive than a stricter safe one. We further characterize the maximally permissive least-intrusive supervisor as a value-threshold refinement of the conventional one. This refinement is computed from a proposer model, i.e., an estimate of the probability that the agent proposes each action. Since the refinement only removes transitions from the conventional supervisor, it is safe even if this estimate is wrong.

Third, for two actions that may run in either order, we give precise conditions under which this refinement either leaves their order free or fixes it by one monitor place. On an autonomous release agent, we find by synthesis that safe deployment requires a step that the supervisor can refuse after a rollout starts, since otherwise the release could go live after an incident has frozen releases. A two-phase rollout provides such a step. For an illustrative proposer that requests a premature deployment only after the tests, the refinement puts the security scan first if and only if such a request has probability above 43/60.

We call the execution harness certified because its guarantees are proven and do not rely on testing. In particular, its safety holds on the net for every sequence of proposals and environment moves and, under the four assumptions above, also in the running system. Moreover, the least-intrusive refinement is optimal for a given proposer model, which can be checked independently of how the refinement was computed.

The rest of this paper is organized as follows. Section II reviews related work, while Section III recalls the basics of Petri nets and state-feedback supervisors. Section IV introduces the AEPN and its admission rule, derives the maximally permissive supervisor, and states the four assumptions under which safety transfers to the running system. Section V introduces the replanning closed loop and characterizes the maximally permissive least-intrusive supervisor, including how it orders concurrent actions. Section VI applies the safety and least-intrusiveness results to an autonomous release agent. Conclusions are drawn in Section VII.

References (36)