Server and agent runs

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

Agent server

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

Agent runs

These three are called for the agent that search matched or that execAgent named.

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, 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 receives an error saying that 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 receives an error saying that the agent was deleted and the hook failed.agentName.