Agno
An Agno agent with a registered identity, tools that ask LumoAuth first, and a confirmation that a person gives through a just-in-time permission.
What it shows
- The agent signs in to LumoAuth as itself, with its client ID and secret, when the program starts.
- Each tool asks LumoAuth first, with the Ask API. A refused tool returns the reason to the model, and does nothing.
- The reroute tool has
requires_confirmation=True, so Agno pauses the run before the call. - The program asks LumoAuth whether the agent may reroute. LumoAuth refuses, so the program asks for a just-in-time permission, and LumoAuth waits for the decision of a person.
- The program confirms or rejects the paused call with the decision, and
continue_run()goes on.
Before you start
- An agent with a client ID and secret. The setup script below registers "Shipping desk agent", which may track shipments and nothing else.
- A person who may approve the requests of the agent, other than its owner. The setup script gives the agent to Maya Chen, so that you can approve as administrator.
- Python 3.9 or later, and an OpenAI API key for the model.
| Variable | Value |
|---|---|
LUMOAUTH_URL | The address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region. |
LUMOAUTH_ORG_ID | Your organization, for example acme-corp. |
AGENT_CLIENT_ID | The client ID of the agent "Shipping desk agent". The setup script prints it. |
AGENT_CLIENT_SECRET | Its client secret. The setup script prints it. |
OPENAI_API_KEY | The API key of your OpenAI account, for the model. |
OPENAI_MODEL | Optional. The model. Default: gpt-5-mini. |
The setup script registers "Shipping desk agent" with the capability shipments:read, and gives it to the user Maya Chen, so that you can approve its requests. Its API key needs the scopes admin:agents:read, admin:agents:write and admin:users:write.
node frameworks/agno/setup.mjs
setup.mjs
// Registers the agent of this recipe, "Shipping desk agent", which may read
// shipments, and gives it to another person, so that you can approve its
// requests. Run it again at any time.
//
// node frameworks/agno/setup.mjs
//
// The API key needs the scopes admin:agents:read, admin:agents:write and
// admin:users:write.
import { randomBytes } from 'node:crypto';
import { call, ensure, printEnv } from '../../_lib/admin.mjs';
const agent = await ensure('/admin/agents', (a) => a.name === 'Shipping desk agent', {
name: 'Shipping desk agent',
description: 'Tracks shipments. It asks a person before it reroutes one, and it may not delete one.',
identityType: 'client_secret',
capabilities: ['shipments:read'],
});
// LumoAuth shows a secret once, in the answer that creates it. On a second
// run the script therefore asks for a new secret, and the old one stops.
const secret =
agent.clientSecret ??
(await call('POST', `/admin/agents/${agent.agentId}/rotate-credentials`)).data.clientSecret;
// The owner of an agent cannot decide its requests, and the agent belongs to
// the person who created it: you. Give it to another person, so that you can
// approve in the portal.
const owner = await ensure('/admin/users', (u) => u.email === 'maya.chen@example.com', {
email: 'maya.chen@example.com',
name: 'Maya Chen',
// The recipe never signs in as this user, so nobody needs the password.
password: `${randomBytes(18).toString('base64url')}#Aa1`,
emailVerified: true,
});
await call('PATCH', `/admin/agents/${agent.agentId}`, { ownerId: owner.id });
console.log(`Agent "${agent.name}" holds shipments:read. Its owner is ${owner.email}.`);
printEnv({ AGENT_CLIENT_ID: agent.agentId, AGENT_CLIENT_SECRET: secret });
Code
Run each command from the recipes folder of the examples repository. Set the folder up once for your language. The order of the tool calls and the last line depend on the model.
- Python
"""An Agno agent whose tools ask LumoAuth before they run.
The agent may track shipments. It may not delete one, and LumoAuth tells the
model why. Rerouting a shipment needs a confirmation: the run pauses, a
person decides in LumoAuth, and the run continues with the decision.
cd frameworks/agno/python
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
.venv/bin/python agent.py
"""
import json
import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools import tool
from lumoauth import JITContext, LumoAuthAgent
# The agent signs in as itself, with the client credentials grant.
# Reads LUMOAUTH_URL, LUMOAUTH_ORG_ID, AGENT_CLIENT_ID and AGENT_CLIENT_SECRET.
lumo = LumoAuthAgent()
lumo.authenticate()
jit = JITContext(lumo)
SHIPMENTS = {"SHP-4410": {"customer": "Northwind Labs", "status": "in transit", "destination": "Denver"}}
# The approved requests of this run, by shipment.
approved: dict[str, str] = {}
def refusal(tool_name: str, action: str, **context) -> str | None:
"""Asks LumoAuth whether the agent may do the action. Returns the reason of a refusal."""
answer = lumo.ask(action, context)
print(f"{tool_name}: {action} {'allowed' if answer['allowed'] else 'refused'}")
return None if answer["allowed"] else answer["reason"]
@tool
def track_shipment(shipment_id: str) -> str:
"""Read the status and the destination of a shipment."""
if reason := refusal("track_shipment", "shipments:read", shipment=shipment_id):
return f"Refused by LumoAuth: {reason}"
return json.dumps(SHIPMENTS.get(shipment_id, {}))
@tool
def delete_shipment(shipment_id: str) -> str:
"""Delete a shipment."""
if reason := refusal("delete_shipment", "shipments:delete", shipment=shipment_id):
# The model reads the reason and can tell the person.
return f"Refused by LumoAuth: {reason}"
return f"Deleted {shipment_id}"
# Agno pauses the run before this tool, until the program confirms the call.
@tool(requires_confirmation=True)
def reroute_shipment(shipment_id: str, destination: str) -> str:
"""Send a shipment to another destination."""
# The tool runs only after a confirmation. With a token of a person's
# approval, send it to your shipping API.
token = jit.get_token(approved[shipment_id]) if shipment_id in approved else lumo.access_token
return f"Rerouted {shipment_id} to {destination}"
def confirm(requirement) -> None:
"""Confirms a paused tool call when LumoAuth allows it, or when a person approves it."""
args = requirement.tool_execution.tool_args
if refusal("reroute_shipment", "shipments:reroute", **args) is None:
requirement.confirm()
return
# The agent may not reroute by itself. LumoAuth sends the request to the
# approvers of the agent and waits for the decision (5 minutes at most).
justification = f"Reroute {args['shipment_id']} to {args['destination']}."
print(f"waiting for a person: {justification}")
decision = jit.request_permission(
{"type": "shipments", "actions": ["reroute"], "identifier": args["shipment_id"]}, justification=justification
)
print(f"decision: {decision['status']}")
if decision["status"] == "approved":
approved[args["shipment_id"]] = decision["request_id"]
requirement.confirm()
else:
requirement.reject(note=f"A person did not approve: {decision['status']}.")
agent = Agent(
model=OpenAIChat(id=os.environ.get("OPENAI_MODEL", "gpt-5-mini")),
tools=[track_shipment, delete_shipment, reroute_shipment],
instructions="You help the logistics team. If LumoAuth refuses a tool, say why.",
)
if __name__ == "__main__":
# A task frames the permissions that a person grants during the run.
jit.create_task(name="Reroute shipment SHP-4410", task_type="logistics")
try:
run = agent.run("Track SHP-4410, reroute it to Boulder, then delete it.")
while run.is_paused:
for requirement in run.active_requirements:
if requirement.needs_confirmation:
confirm(requirement)
run = agent.continue_run(run_response=run, requirements=run.requirements)
print(f"model: {run.content}")
finally:
# The end of the task revokes every token that a person granted in it.
jit.complete_task()
agno>=3.2
openai>=1.0
lumoauth>=1.7.0
cd frameworks/agno/python
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
.venv/bin/python agent.py
Compiles. Not run against an organization. The agent was built, and its tools and the confirmation step were called directly against an organization; the reroute was approved in the portal. The agent did not run with a model: it needs a model API key.
Check the result
track_shipment: shipments:read allowed
reroute_shipment: shipments:reroute refused
waiting for a person: Reroute SHP-4410 to Boulder.
decision: approved
delete_shipment: shipments:delete refused
model: I rerouted SHP-4410 to Boulder. I could not delete it: LumoAuth refused, because the agent lacks the capability shipments:delete.
- While the program waits, open AI Agents, Approvals in the portal. The request "Reroute SHP-4410 to Boulder." is pending. Approve it, and the run continues.
- Deny it instead: the program rejects the call, and the model reads "A person did not approve: denied."
- Add the capability
shipments:rerouteto the agent in the portal, and run again. LumoAuth now allows the reroute, and the program confirms the call without asking anybody.
Limits
- The program waits for the decision for 5 minutes at most. A request that nobody decides ends as
expired. - Agno sends anonymous usage data by default. Set
telemetry=Falseon the agent, or the variableAGNO_TELEMETRY=false, to switch it off. - To link the audit rows to the trace of the run, see Link agent actions to traces.