The ProbeAgent hooks system provides an event-driven callback mechanism for monitoring and customizing agent behavior. It allows developers to implement logging, analytics, debugging, and custom integrations by subscribing to specific events throughout the agent's lifecycle, message processing, tool execution, and AI streaming phases.
Callbacks can be synchronous or asynchronous and execute in parallel. The system features error isolation, meaning a failure in one hook callback will not prevent other hooks from running or crash the agent.
const agent = new ProbeAgent({
path: './src',
hooks: {
'tool:start': (data) => console.log(`Tool: ${data.name}`),
'tool:end': (data) => console.log(`Done: ${data.name} (${data.duration}ms)`),
'message:user': (data) => logMessage('user', data.message)
}
});