如何為每次 AI 智能體執行設定短期、任務限定身份
Give each AI agent run its own short-lived, task-scoped identity
Tyler Akidau主張,AI 智能體每次執行都應使用綁定單一任務、短期有效的身份,並由模型無法讀取或修改的基礎設施檢查工具呼叫。授權應取委派者權限與智能體允許規則的交集,拒絕規則優先,並記錄每次執行的提示詞、輸入、工具請求、工具回應及輸出。文章附有 Python 授權示例,並建議以 OpenTelemetry 匯出追蹤資料。
Give every agent run a fresh identity bound to one task, let it expire fast, and check each tool call in infrastructure the model can't read or change. Then record every prompt, tool request, tool response and output. Rules in the system prompt help, but they can't be the thing that stops an agent from touching customer data or money.
Tyler Akidau is chief technology and product officer at Redpanda. He laid out this governance layer on Chain of Thought in May 2026, building on his O'Reilly Radar piece about why nobody built HR for agents.
Why can't prompt rules limit what an agent does?
Instructions the agent reads can't be the only thing enforcing a rule. Akidau calls prompts and trained guard models inbound controls, and says they will at some point collapse under prompt injection or hallucination. Akidau's comparison: telling an agent never to delete the database is like keeping all of the company's cash in a room with no lock and asking people not to take any. "It's fine until it's not."
His rule is to enforce limits out of band, through channels the agent can't access, modify or see. Treat the prompt as guidance. Put anything that must hold in the tool gateway, the identity provider and the policy layer.
How do you scope an agent's credentials to one task?
Service accounts assume software that behaves the same way every time, with a fixed role. Agents are non-deterministic and easy to clone, so Akidau argues each instance needs its own identity for the task it's running:
you need each agent instance for any given specific tasks it's running to have an identity, nailing down like this instance is, you know, this version of the agent bound to this task. short-lived, you know, it's essentially every time you get asking you to go do something, it gets a new badge.
Tyler Akidau, chief technology and product officer at Redpanda, on Chain of Thought ep 60
We Built Agents, Nobody Built … - Chain of Thought | AI Agents, Infrastructure & Engineering - Apple Podcasts
Podcast Episode · Chain of Thought | AI Agents, Infrastructure & Engineering · May 27 · 51m
podcasts.apple.com
That identity also records who delegated the work, so every action traces back to a human (or to an agent acting for one). Authorization on top of it should be:
- Narrow: scoped to the job, not to everything the agent might ever need.
- Short-lived: a job granted billing access for a 2 p.m. run shouldn't still hold it an hour later.
- Deny-capable: you can say "this agent can never write to the production database" and have that stick.
- Intersection-aware: the agent gets only the overlap between the delegating human's permissions and its own rules.
The last point is his guest-badge model:
you can get a guest badge and you can kind of go anywhere that a human will take you. But even if the human has access to the secret server room that guests aren't allowed in, you're still not allowed to go because you've got the guest badge.
Tyler Akidau, chief technology and product officer at Redpanda, on Chain of Thought ep 60
A minimal sketch to adapt. log_event and is_revoked are hypothetical hooks into your trace pipeline and revocation list.
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
@dataclass(frozen=True)
class Grant:
grant_id: str
instance_id: str # the agent instance this run is bound to
task_id: str
delegator: str # the human (or agent) who asked for this run
expires_at: datetime
allowed: frozenset # {("billing_db", "read"), ...}
def mint_grant(grant_id, instance_id, task_id, delegator,
human_perms, agent_allow, agent_deny, ttl):
effective = (human_perms & agent_allow) - agent_deny # denies always win
return Grant(grant_id, instance_id, task_id, delegator,
datetime.now(timezone.utc) + ttl, frozenset(effective))
def authorize(grant, ctx, resource, action, is_revoked, log_event):
# ctx comes from the runtime (who is actually calling), not from the model
ok = (datetime.now(timezone.utc) < grant.expires_at
and ctx.instance_id == grant.instance_id
and ctx.task_id == grant.task_id
and not is_revoked(grant.grant_id)
and (resource, action) in grant.allowed)
log_event("authz", {"grant": grant.grant_id, "by": grant.delegator,
"perm": (resource, action), "allowed": ok})
return ok
Call authorize in the tool layer, before the tool runs. The check holds whatever the model has been told, because the model can't change the grant, the caller context or the revocation list.
What should you record for every agent run?
Everything. You can't debug a model the way you debug a bad if-statement, so Akidau's answer is to record every prompt, input, tool request, tool response and output, then build observability, after-the-fact explanations and automated evals on that record. His example of why it matters: a customer service Slack bot that worked well for two or three weeks, then started giving customers suggestions that made no sense. Without the history, you can't see when or why behavior shifted.
For the format, he recommends starting with OpenTelemetry, which is what Redpanda uses in the system it is building, so traces can leave whatever agent framework produced them and land in one place.
How do you enforce limits the model never sees?
Put the limit where the action executes, not where the agent decides. Akidau described a wealth-management demo from a workshop paper: you might set parameters for automatic trading, but any trade with more than, say, $1,000 of portfolio impact always goes to a human for review. The agent can't get around it, and it doesn't know the check exists.
The same identity layer gives you a kill switch. If every instance has its own identity and authorization is dynamic, stopping a misbehaving agent (or a whole class of them) means revoking access in one place. In his words, chain of responsibility and the kill switch are "largely dependent on just saying, look, solve identity and authorization properly."
FAQ
Is a system prompt or skills file enough to restrict a production agent?
Not for customer data or money. The agent can read those instructions and still fail to follow them. Enforce the rule in infrastructure it can't reach.
How is agent identity different from a service account?
A service account has a fixed role and assumes predictable behavior. An agent instance gets a fresh identity per task, with a short expiry and a record of who delegated the work.
Do you need a separate kill-switch system?
Akidau's view is that it falls out of identity and authorization done well: revoke the grants (the is_revoked check above) and the agent stops.
Takeaway
- Enforce policy out of band, in tool gateways and authorization the agent can't see or edit.
- Mint a new short-lived identity per task, with the delegating human attached.
- Compute permissions as the intersection of human grants and agent rules, with denies winning.
- Record every prompt, input, tool call, tool response and output, and export traces in a standard format such as OpenTelemetry.
- Put money limits, write bans and human review on the infrastructure side.
The full conversation, with the transcript, is on Chain of Thought.
Subscribe to the Chain of Thought newsletter for new episodes and write-ups like this one.
Drafted with AI assistance from the episode transcripts.
來源:DEV Community · dev.to