An LLM Tool Call Is Not an Authorized Business Operation
AI agents are becoming more than just conversational interfaces. They can call APIs, retrieve information, update databases, create records and trigger operations inside real applications.
But there is an important distinction that I think developers should never overlook: an LLM-generated tool call is a proposed action, not an authorized business operation.
A model can generate perfectly valid JSON, choose the correct tool and even provide all the required arguments. Yet the operation can still be unauthorized, invalid or unsafe to execute.
This is where AI engineering starts intersecting with traditional backend engineering, and where treating an agent as just another API client can become dangerous.
1. Tool schemas validate structure, not authority
Suppose we build an AI assistant for an internal inventory management system. The assistant has a tool that allows it to adjust inventory quantities.
The model might generate the following tool call:
{
"item_id": "FRASS",
"site_id": "SITE-07",
"quantity_delta": -12,
"reason": "Verified stock count correction"
}
The arguments look reasonable. They are structured, contain the required fields and could pass a JSON schema validator.
But several questions remain unanswered:
- Is the user allowed to modify inventory?
- Does the user have access to SITE-07?
- Is this adjustment permitted under the current business rules?
- Is the quantity within an acceptable range?
- Does this operation require approval?
- Has this adjustment already been executed?
A schema validator can help answer whether the input follows a defined structure. It cannot establish whether the authenticated user has the authority to perform the requested operation.
That responsibility belongs to the application.
2. Treat the AI agent as an untrusted client
One of the architectural decisions I would make when building an agent-enabled backend is to avoid allowing the model to directly control business operations.
Instead, the agent should interact with a controlled execution layer.
The model proposes an action. The application decides whether that action can actually happen.
For example, the architecture could look like this:
User Request
|
v
LLM Agent
|
| Proposed tool call
v
Tool Execution Gateway
|
+-- Input Validation
+-- User Identity
+-- Permission Checks
+-- Business Rules
+-- Idempotency
+-- Approval Policy
|
v
Application Service
|
v
Database / Business Operation
|
v
Structured Result
|
v
LLM Agent
The execution gateway becomes the boundary between model-generated intent and actual application behavior.
This approach also makes the system easier to maintain because the business operation does not need a completely separate implementation just because an AI agent is calling it.
The agent should ideally use the same application services and business rules that the regular frontend or API uses.
3. Never trust the model to provide its own authority
Consider a tool that accepts a site ID.
{
"site_id": "SITE-07",
"action": "adjust_inventory"
}
The model should be allowed to provide the target resource it wants to operate on, but the application must independently determine whether the authenticated user is permitted to access that resource.
I would not trust arguments such as user_id, tenant_id, role or allowed_sites generated by the model as proof of authority.
Those values should come from the authenticated application context.
A simplified FastAPI example:
async def execute_inventory_adjustment(
request: InventoryAdjustmentRequest,
user: CurrentUser,
):
await permissions.require_action(
user=user,
site_id=request.site_id,
module="inventory",
action="edit",
)
return await inventory_service.adjust(
user=user,
request=request,
)
Here, user comes from the application's authentication layer, not from the model's generated arguments.
The permission check happens before the business operation is executed.
Even if the model tries to select another site, the backend must still enforce the permissions associated with the authenticated user.
This is not an AI-specific security principle. It is the same server-side authorization principle we should already be applying to regular APIs.
The difference is that an AI agent may generate unexpected combinations of arguments more frequently, making these boundaries even more important.
4. Tool execution must be designed for retries
This is another problem that can easily be overlooked.
Imagine the agent requests an inventory adjustment. The backend executes the operation successfully, but the response times out before reaching the agent.
The model may not know whether the operation succeeded.
It might attempt the same tool call again.
If the backend blindly executes every request, the same inventory adjustment could happen twice.
For operations that modify data, I would introduce an idempotency mechanism.
For example, each logical execution could have a unique execution key:
execution_key: agent-action-81f2c
The backend would associate that key with the intended operation and its result.
A simplified service-level example:
async def adjust_inventory(
request: InventoryAdjustmentRequest,
idempotency_key: str,
):
existing = await execution_repository.get_by_key(
idempotency_key
)
if existing:
return existing.result
return await repository.execute_adjustment(
request=request,
idempotency_key=idempotency_key,
)
This example illustrates the idea, not a complete concurrent-safe implementation. In production, the idempotency record, business operation and result should be coordinated transactionally where possible, with a database uniqueness constraint and appropriate handling of concurrent requests.
A simple lookup followed by an insert is not enough because two requests can arrive simultaneously.
There is also an important distinction between a model call ID and a business execution ID. The model may generate another tool call during a retry or a new reasoning turn, but that does not necessarily mean a new business operation should be created.
For a retry of the same logical operation, the backend needs a stable execution identity.
5. Not every tool call should execute immediately
Some operations are harmless. Others can have significant consequences.
Reading a dashboard metric is different from modifying inventory, deleting a record or initiating a financial transaction.
I would classify tools according to their impact and introduce approval requirements where necessary.
For example:
| Operation |
Execution policy |
| Read dashboard metrics |
Execute after authorization |
| Retrieve inventory details |
Execute after authorization |
| Update a configuration |
Validate and authorize |
| Large inventory adjustment |
Require approval |
| Delete a critical record |
Require explicit confirmation and policy checks |
For high-impact operations, the agent could create an action request instead of immediately executing it.
The request could move through states such as:
PENDING_APPROVAL → APPROVED → EXECUTING → SUCCEEDED
Or:
PENDING_APPROVAL → REJECTED
The approval should be tied to the exact action and its normalized arguments. If the arguments change after approval, the previous approval should no longer authorize the modified operation.
The model can assist with preparing the request, explaining the impact and presenting it to the user, but the application should control the approval process.
6. Audit and test the execution boundary
If an AI agent can modify production data, its actions should be traceable.
I would record details such as:
- Authenticated user who initiated the request
- Tool name and execution ID
- Normalized tool arguments
- Authorization decision
- Approval details, where applicable
- Execution status
- Result or failure reason
- Timestamps
Sensitive information should be appropriately redacted rather than blindly logging every tool argument.
I would also test the tool execution layer independently of the LLM.
Some tests I would consider essential:
- A user cannot modify a resource belonging to another site.
- A user with read-only permission cannot execute a write tool.
- Invalid arguments are rejected before the operation executes.
- Repeating the same idempotency key does not repeat the business operation.
- Reusing an idempotency key with conflicting arguments is rejected.
- An unapproved operation cannot bypass the approval workflow.
- Concurrent duplicate requests do not create duplicate business records.
These tests help verify that the security and reliability of the application do not depend on the model behaving correctly.
Conclusion
Building an AI agent that can call tools is relatively straightforward. Building one that can safely interact with real business systems requires a much more deliberate architecture.
The model should be responsible for understanding requests and proposing actions. The backend should remain responsible for authentication, authorization, validation, business rules, execution, auditability and recovery.
I believe this is one of the most important design principles for production AI applications: the intelligence of the model should not replace the enforcement mechanisms of the software.
An agent can make a decision about what it wants to do. The application must still decide whether it is allowed to do it.
That boundary is what makes an AI-powered application a reliable software system rather than simply an LLM connected to a collection of APIs.
AI agentsLLM tool callsauthorizationtool executionidempotencybackend securitybusiness rules
Arun PottiPosted Nov 26, 2026, 10:56 PM
Good Article.