The agent action space is the set of actions an autonomous agent is actually able to choose from at each step: the tools it can call, the argument values it can supply, and the state changes those calls are allowed to produce. Developers constrain that set when they decide, in advance and in code, which actions exist at all, which arguments are valid, and which actions need a human decision before they run. That decision matters because an agent does not merely answer a question; it acts. A prompt can ask an agent to behave safely, but only the action space determines what it can do when the model hallucinates, or when instructions hidden in content it reads steer it off task.
This guide gives developers a practical method for defining, narrowing, enforcing, and widening that set only on evidence.
What an agent action space is
The term comes from reinforcement learning, where the action space is the set of all possible actions in an environment. A discrete action space is finite: the reinforcement-learning course published by Hugging Face uses Super Mario Bros as its example, with four possible actions. For a language-model agent, each tool call carries arguments that decide what that step does to a system, a file, or a record.
Three distinctions keep the concept useful. First, the action space is not the tools installed in a project. A tool that is installed but never exposed to the agent is not in its action space, while the same tool exposed with broad arguments has a much larger action space than when it is exposed with a narrow schema. Second, it is not the permissions held by the service identity. Permissions decide what the downstream system will accept; the action space decides what the planner can even propose. Third, it can depend on state. Some combinations are valid in one state and invalid in another, for example issuing a refund only when an order is in a refundable state. A fixed list of tool names cannot express that, so the harness must check the current state before it allows the call.
Map the action space before you build it
Start by enumerating the action space. List every action the agent could take in the course of its task, including reading, writing, sending, and executing. For each action, record what it touches, whether its effect can be undone, what data it can expose, and how bad the worst plausible misuse would be.
Write down the intended scope as well as the inventory: the task in one sentence, the actions it requires, and the actions explicitly out of scope. A support agent may need to read tickets and add internal notes; it does not need to delete tickets, change billing records, or run arbitrary shell commands, even if those capabilities exist in the same codebase.
Test the map against two questions. Which actions could an instruction hidden in content the agent reads reach, if it succeeded? OWASP lists hallucination and direct or indirect prompt injection among the triggers for excessive agency. And which actions would still be harmful if the model simply made an ordinary mistake? Excessive agency, in OWASP’s definition, is the vulnerability that enables damaging actions in response to unexpected, ambiguous, or manipulated model outputs, regardless of the trigger. The action space must be safe under error as well as under attack.
Narrow the tool set to the task
The highest-leverage constraint is the simplest: expose fewer tools. OWASP’s prevention guidance for excessive agency begins with minimising tools, minimising tool functionality, and avoiding open-ended tools. Limit the tools an agent may call to only the minimum necessary. If a system does not need to fetch the contents of a URL, it should not offer a URL-fetching tool. If a mailbox tool exists only to summarise mail, it should contain read capability only, not the ability to delete or send messages.
Split tools along the lines the task needs. Give the agent a read-only tool and a separate, narrower write tool rather than one tool that can do both, and prefer task-specific tools over general-purpose ones. OWASP contrasts a general shell-command tool, whose scope for undesirable actions is very large, with a specific file-writing tool that implements only the one function the application needs.
Apply the same rule where tools arrive through a server or gateway, such as a Model Context Protocol server. The set of tools the server lists bounds what the agent can see and therefore what it can propose. Removing a tool from that list removes it from the action space; leaving it listed and relying on a prompt to discourage its use does not.
Constrain arguments, targets and state transitions

Narrowing the tool set is not enough. A permitted tool with unconstrained arguments is still open-ended: a file tool accepting any path can read outside its intended directory. The second dimension of the action space is the argument space: the values, targets, and state transitions each tool may carry.
Use a strict schema for every tool’s arguments. Name each argument, give it a type, mark the required arguments, and restrict values with enums, ranges, and allowed target identifiers wherever the task allows it. The schema alone, however, does not authorise anything. Application code must validate the arguments against the schema and the current state before execution, and must reject or clamp out-of-range values with a defined fallback instead of silently correcting them.
The following fragment shows the shape of a narrow tool definition only. It is not a complete program, and field names follow the input-schema naming described in the research; check the current provider documentation before copying the shape into a real integration.
{
"name": "get_ticket",
"description": "Read one support ticket by its identifier. Read-only. Use this tool only to inspect a ticket the user named.",
"input_schema": {
"type": "object",
"properties": {
"ticket_id": {
"type": "string",
"description": "The ticket identifier, for example T-1042."
},
"status": {
"type": "string",
"enum": ["open", "pending", "resolved"]
}
},
"required": ["ticket_id"]
}
}The fragment contains no delete, update, or send operation and no argument selecting a different customer. Adding a write operation, a wildcard target, or an open-ended query field would widen the action space, and each such addition should be a deliberate, reviewed decision. State checks belong beside schema checks: before a state-changing call runs, verify that the target is in a state where the action is valid and that any precondition still holds.
Enforce the action space in code, not in the prompt

Constraints that live only in a prompt are instructions to a system that can be misdirected. Constraints in the harness are checks that run whether or not the model understood them. OWASP’s complete-mediation principle states the point directly: implement authorisation in logic rather than relying on a model to decide whether an action is allowed, and validate every request to a downstream system against a security policy in the tool, in an independent pre-execution decision point, or in the downstream system itself.
Guardrails put those checks into the harness. The OpenAI Agents SDK documents three guardrail families: input guardrails on the initial user input, output guardrails on the final agent output, and tool guardrails around each function-tool invocation. Tool guardrails are the most relevant here, because they run on every guarded invocation, with input checks before execution and output checks after it, and they can allow the call, reject it with a message, or raise a tripwire that halts execution. Agent-level guardrails alone cannot substitute for per-tool checks in a multi-agent workflow.
Programmable rails offer a related pattern in other stacks. NVIDIA’s NeMo Guardrails toolkit lets developers define rules that are user-defined, independent of the underlying model, and interpretable,
Human approval is the control for actions that are permitted but high-impact. OpenAI’s guidance distinguishes guardrails, which validate automatically, from human review, which pauses the run so a person can approve or reject a sensitive action before side effects such as cancellations, edits, or shell commands occur. LangChain’s human-in-the-loop middleware implements the same idea: it checks each tool call against a configurable policy, pauses execution, saves the graph state so execution can resume later, and lets the reviewer approve the call, edit its arguments, reject it with feedback, or respond directly. Let low-impact, reversible actions run automatically.
Identity, permissions, and sandboxing are outer bounds, not substitutes. Run each tool with the least permission its task needs, in the context of the user it serves. Run generated or untrusted code in an isolated sandbox rather than on the host: sandbox tools for frameworks such as CrewAI run agent code in ephemeral virtual machines, and tool output must still be treated as untrusted.
A worked example: narrowing a support agent’s action space
The following example is illustrative, assembled from the patterns above rather than reported from a real deployment. Consider a support agent whose task is to help customers with order and ticket queries. Its first version has a general tool set: read and send mail, read, update, and delete tickets, run shell commands, fetch arbitrary URLs, and update billing records. A prompt-injection attempt hidden in a ticket or email then has a large set of harmful actions to aim at, and the prompt is the only boundary.
In the narrowed version, the agent may read a ticket by identifier, add an internal note, and look up an order by identifier. It may prepare a refund, but not issue one: preparing a refund creates a draft with a fixed amount, a named order, and the ticket identifier, and the draft waits for human approval before any money moves. It has no mail-send tool, no delete tool, no shell tool, and no general URL-fetch tool. Refund drafts are valid only when the order is in a refundable state and the amount is within the range the task defines. A proposal outside that set is refused by the harness before execution, and the refusal tells the planner which valid action to choose instead. Widening it again would need its own schema, state checks, approval rule, and tests.
Test, monitor and widen the action space deliberately
Write misuse cases that try to reach actions outside the defined set: ask the agent, through ordinary messages and through content it reads, to delete records, change recipients, widen argument values, and call tools that are not exposed. Each attempt should end in a refusal by the harness, If a test reaches a harmful action, the finding is a defect in the action space, not a prompt-tuning task.
Log every denied action with the tool name, the arguments proposed, the rule that refused it, and the state at the time, so the team can see whether refusals cluster around one misunderstood tool or a repeated misuse pattern. The following fragment shows the shape of such a log record only; it is not a complete logging implementation, and field names are illustrative.
{
"decision": "denied",
"tool": "issue_refund",
"rule": "amount_out_of_range",
"order_state": "shipped",
"requested_amount": 250,
"allowed_maximum": 100,
"reviewed": false
}Review the log when anyone proposes widening the action space. A widening is justified when there is evidence the wider set is needed, when the new actions have schemas, state checks, and approval rules defined, and when misuse tests cover them. Common mistakes run in the opposite direction: constraints written only in a prompt, broad tools kept for convenience, a widening approved without tests, and a guardrail treated as authorisation when it only inspects input or output. Record the action space as a maintained document, and review it when the task changes or the log shows an unexpected pattern.
Constraining the action space is a sequence: enumerate, remove, bound, enforce, gate, and test. Done that way, the agent keeps the freedom to do its job, and loses the freedom to do the harm its job never required.












