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
| Hook | When it is called | The dict holds |
onStartOn server start | Once, when the agent server starts. If it raises, the agent server does not start. | Nothing. |
onEndOn server stop | When 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.
| 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, which is 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 gets an error that says 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 gets an error that says the agent was deleted and the hook failed. | agentName. |