You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How do delegation chains work in theAuth? (agent-to-agent permission passing)
#4
A common question: what happens when one agent hands work to a sub-agent?
(This thread was first posted when the project was called kavachOS. The example is rewritten for the current API and for the delegation behavior as it works today. Reference: docs.theauth.dev/delegation.)
The problem
An orchestrator agent has broad permissions. It starts a sub-agent for one task. The sub-agent should get only what that task needs, and for a limited time.
How theAuth handles it
import{createTheAuth}from'@glinr/theauth';consttheauth=awaitcreateTheAuth({database: {provider: 'sqlite',url: 'theauth.db'},});// The parent holds the broad permissionsconstorchestrator=awaittheauth.agent.create({ownerId: 'user-123',name: 'planner',type: 'autonomous',permissions: [{resource: 'mcp:github:*',actions: ['read','write','comment']},{resource: 'mcp:linear:*',actions: ['read','write']},],});// The sub-agent starts with no permissions of its ownconstreviewer=awaittheauth.agent.create({ownerId: 'user-123',name: 'code-reviewer',type: 'delegated',permissions: [],});// Delegate a subset, short livedconstchain=awaittheauth.delegate({fromAgent: orchestrator.id,toAgent: reviewer.id,permissions: [{resource: 'mcp:github:pulls',actions: ['read','comment']}],expiresAt: newDate(Date.now()+30*60_000),// 30 minutesmaxDepth: 1,});
Behavior to know about
The delegated permissions must be a subset of what fromAgent holds. Narrower resources and fewer actions are accepted. Wider resources or new actions throw an error.
The subset check runs against the delegating agent's own permissions, not permissions it received through another delegation. An agent that holds only delegated permissions cannot re-delegate them.
maxDepth is checked on each delegate() call against the depth of the link being created (1 for a first hop). The default is 3. It is not stored as a ceiling for later hops, so each call needs its own value.
authorize() checks the agent's own permissions first and falls back to its delegated permissions.
theauth.delegation.revoke(chain.id) revokes that link and the active links that start from the receiving agent. Revocation takes effect on the next authorize() call, it does not stop work already in progress.
theauth.delegation.getEffectivePermissions(agentId) returns what an agent currently holds through active delegations.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
A common question: what happens when one agent hands work to a sub-agent?
(This thread was first posted when the project was called kavachOS. The example is rewritten for the current API and for the delegation behavior as it works today. Reference: docs.theauth.dev/delegation.)
The problem
An orchestrator agent has broad permissions. It starts a sub-agent for one task. The sub-agent should get only what that task needs, and for a limited time.
How theAuth handles it
Behavior to know about
fromAgentholds. Narrower resources and fewer actions are accepted. Wider resources or new actions throw an error.maxDepthis checked on eachdelegate()call against the depth of the link being created (1 for a first hop). The default is 3. It is not stored as a ceiling for later hops, so each call needs its own value.authorize()checks the agent's own permissions first and falls back to its delegated permissions.theauth.delegation.revoke(chain.id)revokes that link and the active links that start from the receiving agent. Revocation takes effect on the nextauthorize()call, it does not stop work already in progress.theauth.delegation.getEffectivePermissions(agentId)returns what an agent currently holds through active delegations.Share your delegation patterns below.
All reactions