Delegate to Agent
Create a delegation token that grants limited authority from a user (or another agent) to an agent.
When to use: When a human user wants an AI agent to act on their behalf with specific, bounded permissions.
Prerequisites
Completed Register Agent
Completed Login (user authentication)
gl-iam[postgresql]installed
Delegation Flow

5-Line Core
Step-by-Step
Setup Gateway with Full Provider
Delegation requires both user authentication (to verify the user token) and agent support. Use a full provider with agent support:
Authenticate the User
The delegating user must have a valid token:
Create TaskContext
Every delegation is tied to a specific task — this provides auditability:
Define DelegationScope
Specify exactly what the agent can do:
Create Delegation Token
You've delegated authority to an agent! The agent can now use this token to act on Alice's behalf within the defined scope.
Complete Example
Create delegate_to_agent.py:
Run it:
Expected output:
Common Pitfalls
Expired user token
The delegating user's token must be valid. Refresh if needed.
Scope escalation
Requested scopes must be a subset of the agent's allowed_scopes
Missing task.id
Every delegation requires a TaskContext with a unique id
Agent suspended/revoked
Only ACTIVE agents can receive delegations
No secret_key on gateway
The gateway needs secret_key to sign delegation JWTs
Next Steps
Validate Delegation Token — Validate tokens in receiving services
Delegation Chain — Build multi-hop delegation chains
Scope & Budget — Fine-tune scope attenuation and action budgets
Found an issue on this page? Report it on our feedback form.
Last updated
Was this helpful?