Agent-Native CLI Security Starts at the Tenant Boundary
A command-line interface (CLI) for artificial intelligence (AI) agents can make an operation dependable and still make the wrong operation happen faster. Agent-native CLI security starts with a less glamorous question than command syntax: whose data can this action change, and what evidence will remain afterward?
That distinction matters in a commerce platform like Dagango.com. I have spent years building multi-tenant software, including a Next.js and FastAPI monorepo. The design criteria below are for that kind of system; they are not claims about features implemented by CLI-Anything.
Agent-native CLI security is not an authorization model
The appeal of a CLI for agents is real. A graphical user interface (GUI) agent can misread a button, lose track of page state, or fail when a layout changes. CLI-Anything’s paper argues for structured commands, explicit state, and deterministic feedback as an alternative to brittle pixel-level interaction. That is a useful reliability target.
Reliability answers whether a tool can perform an operation consistently. Authorization answers whether this caller should be allowed to perform it on this resource. A stable command can answer the first and still fail the second completely.
The attention is easy to see. The GitHub Trending listing captured for the brief showed CLI-Anything gaining 666 stars that day and reaching 67,107 total stars. That indicates developer interest. It says nothing about a security review or production readiness.
The trust question is not theoretical. In issue 64 of the Convex backend skill repository, users raised concerns about an app idea being sent to a remote endpoint. The maintainer said the prompt upload supported a quickstart flow and was discarded after the environment decision. The Hacker News discussion reached 267 points, with commenters challenging the lack of clear notice.
Those are two distinct questions: what the code did, and whether users had enough information to consent. A system can have a benign purpose and still communicate that purpose poorly. Agent tool permissions need to be designed with that same attention to both behavior and disclosure.
How should an agent tool enforce tenant isolation?
In a multi-tenant application, an agent-provided tenant ID is input, not proof of authority. If a caller can choose tenant_id=acme and the server trusts it, a well-formed CLI has only made a cross-tenant mistake easier to automate.
Resolve the tenant from authenticated server-side context, then check that the requested resource belongs to that tenant. The server should also decide which operations the caller can perform. This is the core of AI agent tenant isolation: scope and permission are enforced at the boundary that owns the data.
For each action, make the effective scope visible in the tool response and audit record. A useful record should tell an operator who or what initiated the request, which tenant was in scope, what action was attempted, and whether it completed. Avoid logging secrets or customer payloads simply because a richer record feels convenient.
I would separate the tool surface by impact:
- Read operations return data within the authorized tenant scope.
- Draft operations prepare a change without making it externally visible.
- Commit operations apply the change and carry explicit approval requirements.
This split makes agent tool permissions easier to reason about. For a commerce workflow, publishing a product, issuing a refund, or changing tenant settings can affect customers or money. Let an agent prepare the action, show a preview with its target and consequences, and ask an authorized person to approve the commit.
The approval should be bound to the exact proposed change. If the agent edits the refund amount after approval, that is a different request and needs a new decision. A generic “user approved this session” flag is too broad to serve as an approval boundary.
What should tests prove before deployment?
A successful command is the least interesting test. The boundary cases tell you whether multi-tenant authorization is real or only present in the happy path.
Include tests that try to:
- Read or mutate a resource belonging to another tenant.
- Omit, corrupt, or substitute the tenant scope.
- Retry a request after a timeout or uncertain response.
- Submit a change that exceeds the caller’s allowed action set.
Retries deserve special care for refunds and other non-idempotent operations. An idempotency key lets a repeated request return the original result rather than applying the same effect twice. Verify that the key is scoped correctly, so one tenant cannot collide with another tenant’s request.
Tests should also inspect the audit trail. A denied cross-tenant request should leave enough evidence to investigate the attempt without recording sensitive content. A committed action should be traceable to its initiator, scope, approval, and outcome. If an operation fails halfway through, the record should not falsely imply a successful commit.
For a Next.js and FastAPI monorepo, keep enforcement close to the service that owns the operation. The CLI can validate arguments for usability, but a server-side policy check still needs to run for every request. Otherwise, another client can bypass the CLI and call the same endpoint directly.
FAQ
Can a tenant ID in the tool call be trusted if the agent is authenticated?
No. Authentication establishes which principal made a request; it does not prove that the principal may act on every tenant ID it supplies. Derive or verify tenant scope on the server for every resource access.
Should every agent action require human approval?
No. Read-only and low-impact actions may run under narrowly scoped permissions. Require approval where an action is destructive, financially consequential, or externally visible, and bind the approval to the specific proposed change.
What should the audit log store when a request is denied?
Record the principal, effective tenant scope, attempted operation, decision, and correlation identifier. Do not copy secrets or full customer payloads into the log.
A practical next step is to choose one agent-facing endpoint and map its access boundaries. Before granting access, write down the principal and tenant scope. Add the allowed action and approval condition, then list the audit fields.
Test a request that deliberately names another tenant. If the server cannot explain why it denied that request, operational access is not ready. Keep this checklist for future reviews of the endpoint or its permissions.