Error handling
When a participant handler throws, the environment routes an AgenticError instead of crashing the run.
When any handler throws, the environment catches it and routes it as an AgenticError instead of crashing the run. The participant whose handler threw receives onError(error); every other participant receives onParticipantError(source, error).
After its own onError, the failing participant is marked inactive in that environment, so it stops receiving further events. The rest of the environment keeps running.
import { BaseParticipant, Participant, AgenticError } from '@mozaik-ai/core';
export class ResilientAgent extends BaseParticipant {
onError(error: AgenticError): void {
console.error('my handler threw:', error.message);
}
onParticipantError(source: Participant, error: AgenticError): void {
console.warn(`${source.constructor.name} failed:`, error.message);
}
}AgenticError carries the originating participant (getSource()) and environment (getEnvironment()), so a supervisor participant can inspect where the failure came from and react — for example, re-join the participant, escalate, or log to telemetry.