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
| Hook | When it is called | The dict holds |
onStartOn server start | Once, when the agent server starts. If it raises, the server does not start. | Nothing. |
onEndOn server stop | When 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.
| Hook | When it is called | The dict holds |
onAgentStartOn agent start | Before 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 end | After 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 error | After 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
| Hook | When it is called | The dict holds |
onAgentPublishOn agent publish | After 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 delete | After an agent is deleted. If it raises, the developer receives an error saying that the agent was deleted and the hook failed. | agentName. |