share-nodesDelegate to Agent

Create a delegation token that grants limited authority from a user (or another agent) to an agent.

circle-info

When to use: When a human user wants an AI agent to act on their behalf with specific, bounded permissions.

chevron-rightPrerequisiteshashtag

Delegation Flow

5-Line Core

Step-by-Step

1

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:

2

Authenticate the User

The delegating user must have a valid token:

3

Create TaskContext

Every delegation is tied to a specific task — this provides auditability:

4

Define DelegationScope

Specify exactly what the agent can do:

5

Create Delegation Token

circle-check

Complete Example

Create delegate_to_agent.py:

Run it:

Expected output:

Common Pitfalls

Pitfall
Solution

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


circle-info

Found an issue on this page? Report it on our feedback formarrow-up-right.

Last updated

Was this helpful?