A revocation drill for AI agents, and the caching bug it catches A developer published a ~150-line standard-library Python revocation drill, plus a pytest file, that tests whether an AI agent actually stops after its credential is revoked rather than only whether it can perform tasks. The drill issues a delegated credential, revokes it, retries a tool call, and checks the audit log for a deny event, measuring the time from revocation to stop. It catches a common session-caching pattern that validates a credential once per session and keeps allowing tool calls after revocation, a gap the developer ties to new bank terms from Wells Fargo, Citi and PNC making customers responsible for third-party agents. Most AI agent eval suites test what the agent can do. Very few test whether it stops. That gap got harder to ignore this month. Wells Fargo's new online terms, in effect from November 24, ask customers to revoke any AI agent they let into their accounts and to be able to show evidence they did. Citi, PNC, and others now tell customers they are responsible for what third-party agents do. Proving that an agent stopped is turning into a contract term. So here is a small test you can add to an agent stack this week. I call it a revocation drill: The full code is about 150 lines of standard-library Python plus a pytest file. Link at the end. Three pieces: The credential carries the delegation, not just a secret: @dataclass frozen=True class Credential: token id: str agent id: str on behalf of: str scopes: frozenset str expires at: float The broker's check is boring on purpose. Unknown, revoked, expired, or out of scope means no: php def check self, cred: Credential, scope: str - None: if cred.token id not in self. issued: raise AccessDenied "unknown token" if cred.token id in self. revoked: raise AccessDenied "revoked" if self. clock = cred.expires at: raise AccessDenied "expired" if scope not in cred.scopes: raise AccessDenied "out of scope" This is the important part. The gateway checks the pause flag and the credential on every tool call, and logs the decision either way: php def call self, cred: Credential, tool: str, kwargs - object: scope, fn = self. tools tool base = dict t=self. clock , agent=cred.agent id, on behalf of=cred.on behalf of, token=cred.token id, tool=tool, scope=scope try: if cred.agent id in self. paused: raise AccessDenied "paused" self. broker.check cred, scope except AccessDenied as exc: self. log.record base, decision="deny", reason=exc.reason raise self. log.record base, decision="allow" return fn kwargs Note the pause method on the gateway. That is where alerts should go. An alert that only opens a ticket lets the agent keep running until someone reads it. Here is a pattern that shows up in real code because it saves a lookup per call. Validate once per session, then trust the session: python class SessionCachingGateway ToolGateway : def call self, cred, tool, kwargs : if cred.token id in self. validated: scope, fn = self. tools tool logs "allow" and runs the tool without checking again ... return fn kwargs result = super .call cred, tool, kwargs self. validated.add cred.token id return result It looks fine in a demo. Revoke the credential, and the agent keeps working until the session ends. python def revocation drill gateway, broker, log, tool, scope, clock=time.monotonic, kw : cred = broker.issue "drill-agent", on behalf of="drill-owner", scopes={scope} try: gateway.call cred, tool, kw first ok = True except AccessDenied: first ok = False receipt = broker.revoke cred.token id, revoked by="drill-owner", reason="drill" deny reason = None try: gateway.call cred, tool, kw retry denied = False except AccessDenied as exc: retry denied = True deny reason = exc.reason stop event = next e for e in log.events if e.get "token" == cred.token id and e.get "decision" == "deny" , None revoke to stop = stop event "t" - receipt.revoked at if stop event else None passed = first ok and retry denied and deny reason == "revoked" and stop event is not None return DrillResult passed, first ok, retry denied, deny reason, revoke to stop And the two tests that matter most: python def test drill passes on per call gateway : clock, broker, log, gw = make result = revocation drill gw, broker, log, "read claim", "claims:read", clock=clock, claim id="C-1" assert result.passed assert result.deny reason == "revoked" assert result.revoke to stop seconds == 0.0 def test drill catches session caching gateway : clock, broker, log, gw = make SessionCachingGateway result = revocation drill gw, broker, log, "read claim", "claims:read", clock=clock, claim id="C-1" assert not result.passed assert not result.retry denied the revoked agent kept working The repo has four more tests: scope enforcement, expiry, alert-to-pause with a named human resume, and a check that every log line names both the agent and the principal. All six pass on Python 3.13 with pytest. The clock is injected, so the tests are deterministic. Two numbers per release: The in-process example stops instantly. Real stacks have four common places where a revoked agent keeps going: Each of these is a variant of the same bug as SessionCachingGateway : a decision made once and trusted later. This is a teaching reference, not an auth system. In production, use your identity provider's short-lived tokens, check them at the tool boundary on every call, and ship the audit log somewhere the agent cannot write to. The point of the drill is the test, not the broker. Run the drill three ways before you trust it: a fresh call after revoke, a call from inside a long-running task that started before the revoke, and a call from your framework's retry logic. Cached sessions tend to hide in the last two. Code two files, standard-library Python, 6 tests : https://anilsprasad.com/writing/ai-agent-liability/code/revocation.py https://anilsprasad.com/writing/ai-agent-liability/code/revocation.py and https://anilsprasad.com/writing/ai-agent-liability/code/test revocation.py https://anilsprasad.com/writing/ai-agent-liability/code/test revocation.py I write about production AI in regulated industries at anilsprasad.com https://anilsprasad.com/writing/ . The longer essay on why AI agent liability is landing on whoever grants the access is here: https://anilsprasad.com/writing/ai-agent-liability/ https://anilsprasad.com/writing/ai-agent-liability/ Parts of this article were drafted with AI assistance. I reviewed and edited the text, and the code was run and tested before publishing.