Give each AI agent its own identity, grant only the specific tools and data scopes its task needs, cap what it can do in one run, and write every tool call to an append-only audit log. Approval gates for irreversible actions and a tested kill switch complete the setup, because the model itself cannot be trusted to enforce these limits.
Key takeaways
- Each AI agent should run under its own service identity rather than a shared or personal account.
- Permissions must be enforced by the target system or a gateway in front of it, never by the prompt alone.
- Per-run limits on calls, records and value ranges contain the damage a faulty or manipulated agent can cause.
- Audit logs should record every tool call with its input, output and the rule that allowed it, stored where the agent cannot edit them.
What does tool access mean for an AI agent?
Tool access means the agent can call functions outside the language model, such as reading a database table, creating a draft invoice in an accounting system or sending a message through an API. The model plans the next step, the tool performs the action, and the result returns to the model for the following step.
The risk sits in the tool, not in the model's text. Each tool has inputs, side effects and credentials, and a single call can change a customer record or move money. A badly scoped tool turns a wrong sentence from the model into a wrong change in a live system.
Agents also read untrusted content: emails, uploaded documents and web pages. Instructions hidden in that content can steer the model toward a tool it should not use, which is commonly called prompt injection. For this reason, the controls described below are built outside the model, where a hostile input cannot rewrite them.
How should permissions be scoped?
Scope permissions by giving each agent its own identity and granting each tool the narrowest access that the specific task requires. The target system should enforce these scopes, so a rejected call fails even if the model asks for it.
Choose an identity model
Three common patterns exist, and they differ mainly in how far a mistake can spread and how easily access can be revoked. The table compares them using qualitative criteria.
| Pattern | Blast radius if misused | Revocation effort | Traceability |
|---|---|---|---|
| Shared admin account | Very high: every agent and every script shares the same rights | High: revoking it stops everything | Low: actions look identical across agents |
| Personal user login reused by an agent | High: inherits a person's full access | High: tied to someone's job and habits | Low: actions appear as a staff member |
| Dedicated service identity per agent with scoped tokens | Limited to the agent's task | Low: disable one identity | High: each call maps to one agent |
The third pattern costs more to set up, because each agent needs its own credentials and review cycle. It is still the only one that keeps the consequences of one faulty agent contained.
Personal data and GDPR
If an agent reads or writes personal data, the GDPR applies, and its data minimisation principle requires that personal data be limited to what is necessary for the purpose; check the official text in Regulation (EU) 2016/679 on EUR-Lex. If the agent makes or supports decisions about people, the EU AI Act may also apply, so read the official text in Regulation (EU) 2024/1689 on EUR-Lex to see whether your use case falls under it. This article is general information and not legal or tax advice. Rui Codex provides technical implementation support, not legal, tax or compliance advice, so questions about your obligations belong with qualified counsel.
What limits should you set on agent actions?
Set hard limits on how many calls, records and value ranges an agent may touch in a single run, and require a human approval step above those thresholds. Limits turn an unexpected loop or a misread instruction into a bounded problem.
Useful limits include:
- A maximum number of tool calls per run, so a looping agent stops on its own.
- A maximum number of records that can be created, updated or deleted per run.
- Value thresholds for money, quantities or discounts, above which a person must approve.
- An allow-list of destinations, such as specific email domains or API hosts.
- A dry-run mode in which the agent writes proposed changes to a queue instead of the live system.
- Mandatory approval for actions that cannot be reversed, such as deletions, payments or outbound messages to customers.
Each limit has a cost. Tight thresholds create approval queues, and people who approve many requests tend to stop reading them carefully. Review thresholds regularly against the logs, and remove approvals that never change an outcome.
How do audit logs for AI agents work?
An audit log records each tool call with the time, the agent identity, the input, the output, the policy rule that allowed or rejected it, and the final outcome. The log must be stored where the agent cannot modify or delete entries.
Link the entries of one task together with a shared correlation identifier. That identifier connects the user request, each model step and each tool call, so a reviewer can reconstruct why a change happened.
- Store logs append-only, with restricted read access and a separate retention setting from application logs.
- Record rejected calls as well as successful ones, because rejections show where the model tries to step outside its scope.
- Redact or pseudonymise personal data in inputs and outputs where the purpose does not require it.
- Alert on patterns such as repeated rejections, unusual hours or a sudden rise in call volume.
Logging full prompts is tempting but creates a second store of sensitive data. Log the tool name, parameters in a minimised form and the result, and keep full model transcripts only when a documented need exists.
Where do these controls fail?
These controls fail most often in the gaps between design and daily operation. The main failure is a broad token added during a rushed fix and never removed, which quietly restores the blast radius the design was meant to prevent.
Other common failures include tool descriptions that promise more than the scope allows, multi-agent chains in which one agent passes its rights to another, and logs that nobody reads until an incident. Model-level guardrails help with output quality but should never be the only barrier, because they can be bypassed by content the model reads.
Stricter controls also slow automation. Approval gates add latency, and read-only phases delay value. Accept that trade-off deliberately for each tool, based on how costly a wrong action would be.
Hypothetical examples
Here are two hypothetical scenarios: the first covers an accounts-payable agent, the second a customer-support agent. Neither describes a real organisation, and both show how the same controls apply in different settings.
Invoice processing agent
Imagine an agent that reads supplier invoices and proposes entries in an accounting system. It holds a read scope on the supplier master data and a write scope that only creates draft entries. A misread amount lands in a draft queue, where a finance team member reviews it, and the audit log shows which document and which rule produced the draft.
Customer support agent
Imagine an agent that can issue refunds through a payments API. Its identity allows refunds only below a threshold set by the finance team, and anything above it is routed for approval. If a customer message contains a manipulated instruction, the policy gateway rejects the out-of-scope call, and the rejection appears in the log for review.
Implementation checklist
- List every tool the agent could call, including what each one reads, writes and deletes.
- Create a dedicated service identity for the agent and grant read-only scope first.
- Enforce scopes in the target system or a gateway, not in the prompt.
- Set per-run limits on calls, records and value ranges.
- Add approval gates for every irreversible action.
- Log each call with its correlation identifier, rule and outcome in append-only storage.
- Test the kill switch and a rejected call before going live.
- Review logs and thresholds on a fixed schedule and remove unused permissions.
Conclusion
Safe AI agent tool access rests on three things working together: scoped identities, limits enforced outside the model, and audit logs that cannot be edited by the agent. Start with the smallest set of tools, widen access only after reviewing real logged calls, and keep the kill switch tested. If you want help designing these controls for your own systems, request a project consultation at Rui Codex or email info@ruicodex.com to discuss your project.