How should an agent authenticate to downstream systems? Compare a shared service account with acting on behalf of the user.
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
This is the question that decides whether your audit log means anything. Three options, in increasing order of quality.
Full worked answer with diagram
This is the question that decides whether your audit log means anything. Three options, in increasing order of quality.
Shared service account. The agent holds one credential covering everything any user might need. It is the default because it is the easiest thing to build, and it is the worst outcome: the agent's effective permission is the union of every user's access, so one successful injection reaches all of it. Authorisation collapses into the prompt, which is not a boundary. And the audit log says "ai-agent-svc did it", so after an incident you cannot determine which user's session caused which action. That last part is what turns a two-hour investigation into a two-week one.
On-behalf-of / delegated user token. The agent exchanges the user's session for a downstream token scoped to that user. Now the datastore's existing ACLs do the work, injection is bounded by what that one user could already do, and audit attribution is real. This is the right default, and it has the nice property that you inherit years of authorisation work rather than reinventing it in the agent layer.
Delegated token plus a distinct agent identity. The best answer, because authentication and attribution are different questions. The agent gets its own first-class identity (so you can revoke the agent without disabling the human, and so logs show both principals), and it acts under a downscoped, short-lived token derived from the user's session. Downscoped is the operative word: the user may have write access to 40 repos, but this task needs read on one.
The implementation details that matter: token exchange happens server-side and the model never sees a credential, because anything in the context window is exfiltrable; lifetimes in minutes, not hours, and scoped per session and per tool; a revocation path that works without a deploy; and audit records carrying both the human principal and the agent identity.
The question I would ask any design: if this agent is fully compromised right now, exactly which rows can it touch? A shared service account cannot answer that.
Worth sketching. Same injection, two credential designs, two very different blast radii: the contrast does the arguing for you.
flowchart LR
A["Injection lands"] --> B["Shared service account"]
B --> C["Reach equals the union of every user's access"]
C --> D["Audit says: ai-agent-svc did it"]
A --> E["Delegated, downscoped, short-lived token"]
E --> F["Reach bounded by this one user's ACLs"]
F --> G["Audit carries human and agent identity"]
What a good answer covers
- This is the question that decides whether your audit log means anything
- Three options, in increasing order of quality
- The agent holds one credential covering everything any user might need
- It is the default because it is the easiest thing to build, and it is the worst outcome
- Authorisation collapses into the prompt, which is not a boundary
Key terms: Shared service account · On-behalf-of / delegated user token
Interviewer follow-ups to expect
How do you handle a legitimate background agent that runs when no user is present, so there is no user token to delegate?
What breaks in this model when the agent needs to call a third-party MCP server that does its own OAuth?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep