Interface AgentDefinition<ProcessUserData>

Defines the entrypoint and lifecycle callbacks for an agent.

interface AgentDefinition<ProcessUserData> {
    entry: ((ctx) => Promise<void>);
    onSessionEnd?: ((ctx) => void | Promise<void>);
    onSimulationEnd?: ((ctx) => unknown);
    prewarm?: ((proc) => unknown);
}

Type Parameters

  • ProcessUserData = Record<string, unknown>

Properties

entry: ((ctx) => Promise<void>)

Type declaration

onSessionEnd?: ((ctx) => void | Promise<void>)

Called after the primary agent session closes and before its report is generated. Errors are logged and do not stop session cleanup.

The worker stops waiting after ServerOptions.sessionEndTimeout. JavaScript cannot cancel the returned promise, so timed-out work can continue until the job process exits. The callback is not called if the primary agent session fails to close or exceeds its close timeout.

Type declaration

    • (ctx): void | Promise<void>
    • Parameters

      Returns void | Promise<void>

onSimulationEnd?: ((ctx) => unknown)

Called when a simulation run driving this agent ends. Read the simulator's verdict via ctx.simulatorVerdict and veto a pass from your own checks with ctx.fail(reason). Never called for normal sessions.

Type declaration

prewarm?: ((proc) => unknown)

Type declaration