user-robotRegister Agent

Register an AI agent as a principal in GL IAM so it can receive delegated authority.

circle-info

When to use: Before an agent can participate in delegation, it must be registered with an identity, type, and owner.

chevron-rightPrerequisiteshashtag

5-Line Core

from gl_iam import IAMGateway, AgentRegistration, AgentType
from gl_iam.providers.postgresql import PostgreSQLAgentProvider, PostgreSQLConfig

provider = PostgreSQLAgentProvider(PostgreSQLConfig(database_url="postgresql+asyncpg://user:pass@localhost/mydb", secret_key="your-secret-key-min-32-chars-long!", default_org_id="default"))
gateway = IAMGateway.for_agent_auth(agent_provider=provider, secret_key="your-secret-key-min-32-chars-long!")
result = await gateway.register_agent(AgentRegistration(name="my-worker", agent_type=AgentType.WORKER, owner_user_id="user:alice", operator_org_id="default"))
agent = result.unwrap()  # AgentIdentity

Agent Types

Type
Value
Use Case

Orchestrator

AgentType.ORCHESTRATOR

Coordinates other agents, manages workflows

Worker

AgentType.WORKER

Performs specific tasks (summarize, translate, etc.)

Tool

AgentType.TOOL

Wraps an external tool or API call

Autonomous

AgentType.AUTONOMOUS

Long-running agent with independent decision-making

Step-by-Step

1

Setup Gateway

Create an agent provider and a minimal gateway using for_agent_auth:

2

Create Registration

Define the agent's identity and capabilities:

3

Register Agent

4

Expected Output

circle-check

Complete Example

Create register_agent.py:

Run it:

Expected output:

Common Pitfalls

Pitfall
Solution

Missing owner_user_id

Every agent must have a human owner for accountability

Duplicate agent name

Agent IDs are derived from names (agent:<slugified-name>). Use unique names.

Empty allowed_scopes

An agent with no allowed scopes cannot receive any delegation

Missing secret_key in config

PostgreSQLConfig requires secret_key for JWT operations

Missing default_org_id

Required by PostgreSQLConfig for auto-creating organizations

Next Steps


circle-info

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

Last updated

Was this helpful?