Server and agent runs

Seven hooks follow the life of the agent server and of the agents it runs: one call when the agent server starts and one when it stops, three around each top-level agent run, and one each when an agent is published or deleted. They are the place for your own audit trail, for a check that stops an agent before it runs, and for anything that must happen when a new version goes live.

Agent server

HookWhen it is calledThe dict holds
onStartOn server startOnce, when the agent server starts. If it raises, the agent server does not start.Nothing.
onEndOn server stopWhen the agent server shuts down normally. It is not called when the process is killed. If it raises, the message is logged.Nothing.

Agent runs

These three are called for a top-level agent only: the agent that search matched or that execAgent named. They are not called for an agent that another agent invokes.

HookWhen it is calledThe dict holds
onAgentStartOn agent startBefore the agent runs. If it raises, the agent stops and the user sees the message.convid, agentName, agentVersion, userEmail, query, inputs, isValidation, isNewConversation, and startFromAsk, which is true when the run answers an ask.
onAgentEndOn agent endAfter the agent finishes successfully or pauses on an ask, before the run is recorded. If it raises, the agent fails.The same keys, plus resultCode, endWithAsk and output, the agent's output as JSON.
onAgentErrorOn agent errorAfter the agent fails, before the run is recorded. If it raises, its message is reported as the error instead.The same keys, plus resultCode, errorMessage and path, the command path where the agent failed.

Publishing

HookWhen it is calledThe dict holds
onAgentPublishOn agent publishAfter an agent is published. If it raises, the developer gets an error that says the agent was published and the hook failed.agentName, agentVersion, agentDefinition, agentTitle, agentTag and userEmail, the publisher.
onAgentDeleteOn agent deleteAfter an agent is deleted. If it raises, the developer gets an error that says the agent was deleted and the hook failed.agentName.