2
2 Comments

3 Credential Rules We Added Before Letting AI Agents Call Tools

We keep running into the same pattern when talking to teams building AI agents.

The prototype starts with a key in an env var.

Then the agent gets access to one model, then a search tool, then a database reader, then a ticketing workflow. At some point, the question changes from “does it work?” to “what exactly can this thing do if it goes off path?”


That shift matters.

A normal chatbot can give a bad answer. An agent with tools can take a bad next step.

It can read data, call APIs, retry, create tickets, send requests, or trigger internal workflows. The blast radius is no longer just model output. It is the permission set attached to the agent.


The most dangerous shortcut is giving the agent a long-lived provider key.

It is fast. It works. It gets the demo done.

But it also creates a credential that is hard to scope, hard to attribute, and hard to revoke quickly when something looks wrong.

We have seen three versions of this:


  1. Paste the real provider key into the agent platform.

Easy setup, weak traceability. Later nobody is sure which workflow copied it, which agent used it, or whether it still exists in an old config.


  1. Share one key across the team.

Great until a bill spikes or an audit question appears. You know the key was used. You do not know which agent, user, task, or tool chain caused it.


  1. Give each agent its own key.

Better, but still not enough if those keys are long-lived and broad. You have reduced sharing, not blast radius.


So we started using a stricter mental model while designing AiKey:

Do not give the agent the real key if you can avoid it.

Give it a scoped, temporary capability instead.


Rule 1: credentials should expire.

Many agent tasks are short-lived. A log analysis job may need 10 minutes. A support summary may need one session. A code review workflow may need half an hour.

If the task is temporary, the credential should be temporary too.


This does not eliminate risk, but it shrinks the window.

A leaked long-lived key can keep working until someone notices. A short-lived scoped token dies by default.

That default matters.


Rule 2: credentials should carry policy.

A token should not only say “can call the API.”

It should say: this user, this project, this agent, this environment, these models, these tools, this budget, this time window.

The important part is context.


For example:

A support agent may read the help center and create draft tickets.

It should not export customer records.

A log analysis agent may read staging logs.

It should not change production config.

A reporting agent may query sanitized data.

It should not access raw sensitive fields.


Rule 3: policy checks need to happen at runtime.

Prompt instructions are not access control.

Static review is useful, but agents make decisions while running. They read external content, interpret tool responses, and choose the next call.

The gate has to sit before the action.


Before a model call or tool call happens, the runtime should be able to ask:

Is this token still valid?

Is this tool allowed?

Is this environment allowed?

Is the budget still available?

Does this action require approval?

Should we allow, warn, audit, block, or revoke?


The audit side is just as important.

Most dashboards can tell you which key spent money. That is billing data.

For agents, you need an evidence chain:

Who started the task?

Which agent ran it?

Which tools were called?

Which policies matched?

Which retries happened?

Which action was approved or blocked?

Where should the cost be attributed?


Without that chain, incident response becomes guesswork.

You see an expensive or risky call, but you cannot reconstruct the task that caused it.

That is a bad place to be once agents start touching real systems.


Our conclusion is pretty simple:

Agents can become more autonomous, but their permissions need to become more explicit.

Long-lived API keys were designed for stable services, not semi-autonomous systems that read untrusted input and call tools.


The direction we are building toward with AiKey is:

Real provider keys stay behind a control layer.

Agents receive virtual keys or scoped tokens.

Those tokens are tied to identity, project, model/tool allowlists, budget, environment, and TTL.

The runtime checks policy before the action.

Audit events get attached to the task, not just the key.


It is not the flashiest part of AI infrastructure.

But if agents are going to run inside real teams, credential design becomes part of product safety, cost control, and trust.

The agent can be smart.

The key should still be small.


If you are working on agent access, model routing, API key governance, or cost attribution, we are building around the same problem space at AiKey:

https://aikeylabs.com/zh/i/ih22

Business Inquiries: aikeyfounder@gmail.com

on July 16, 2026
  1. 1

    I like the distinction between model intelligence and permission intelligence.

    As AI agents become more autonomous, the biggest risk isn't necessarily what they say—it's what they're allowed to do. Treating credentials as temporary, scoped capabilities instead of permanent API keys is a sensible direction, especially for production environments.

    One addition I'd consider is making risk levels dynamic. Low-risk actions could execute automatically, while high-impact actions (payments, production changes, data exports) require human approval. That keeps agents efficient without giving them unrestricted autonomy.

    Interesting read—this is an important area as AI agents move from demos to real-world systems.

    1. 1

      Appreciate the push on risk levels. That's in the design — we bucket by blast radius, not by action type. A "low-risk" tool call in staging is different from the same call in production. Policy checks at runtime need to factor in environment, not just the tool name.

      The model intelligence vs. permission intelligence distinction is spot on. Models are getting smarter about what they should do, but the permission layer should be dumb and reliable — check, log, allow or block. No reasoning required.