Lifecycle Management
Runs
Runs track the execution lifecycle of an agent. All events within a run are correlated via run_id. A run.end event is automatically emitted when the context exits:
with alm.run(purpose="Answer user question"):
# Your agent logic here
pass
# run.end event automatically emitted with summary statisticsTasks
Tasks represent logical units of work within a run. They automatically emit task.start and task.end events:
with alm.run():
with alm.task(description="Process input"):
# Task logic
pass
with alm.task(description="Generate output"):
# Task logic
passHandoffs
Handoffs represent agent-to-agent transitions. Emit a handoff event when delegating to another agent:
alm.handoff(
to_agent_id="specialist-agent",
reason="Requires domain expertise",
context={"query": user_query}
)Event Types
run.start– Run startedrun.end– Run finishedtool.request– Tool call initiatedpolicy.decision– Allow or denytool.response– Tool completedtask.start/task.end– Task lifecyclehandoff– Agent-to-agent handoff