Optional agentCalled immediately before an agent starts.
Optional agentCalled after an agent produces its final output.
Optional handoffCalled when control is handed off between agents.
Optional toolCalled when an agent invokes a tool.
Optional errorCalled when an unhandled error occurs inside an agent.
Optional emergentCalled when the emergent subsystem forges a new agent.
Optional guardrailCalled after a guardrail evaluates an input or output.
Optional limitCalled when a resource limit is reached.
Optional approvalCalled when an approval request is raised.
Optional approvalCalled after an approval decision is resolved.
Optional guardrailCalled when the post-approval check overrides an HITL approval: a tool call, an agent run or the final output was approved, and a built-in check matched and vetoed it.
Event callbacks registered on
BaseAgentConfig.on. Each returnsvoid. An agency runs every one inside a try/catch, whichever part of a run fires it (the agency, its strategy, a tool approval or a HITL check): a callback that throws, or an async one whose promise rejects, is written through the host's logger asagency_callback_threw(in an agency with a pool or a panel, with every key the agency can send masked in its message), and never fails the call, changes what it returns or leaves a rejection unhandled. An agency reads each one from theonobject when the run fires it, and none when it is built, so a callback set, replaced or deleted there afteragency()returns is the one that runs, and a getter there that throws is written as a callback that throws is, at its event.