> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> Public events signatures and configuration in @agentium/core 4.0.0.

Import these **7 exports** from `@agentium/core`. Read the [events guide](/agents/events) for setup and behavior, or return to the [package reference](/api-reference/core).

A `?` marks an optional field. These are declarations for lookup; run the examples in the linked guide. Follow related-type links for Agentium types and source links for imported dependency types.

## AgentEventMap

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/types.ts)

```typescript theme={null}
export type AgentEventMap = {
    "controller.start": {
        runId: string;
        controllerCallId: string;
        operation: string;
    };
    "controller.result": {
        runId: string;
        controllerCallId: string;
        operation: string;
        decision?: string;
        modelRole?: string;
        activeToolCount?: number;
    };
    "controller.error": {
        runId: string;
        controllerCallId: string;
        operation: string;
        status: "error" | "cancelled";
    };
    "run.start": {
        runId: string;
        agentName: string;
        input: string;
        sessionId?: string;
        userId?: string;
        tenantId?: string;
        parentRunId?: string;
        rootRunId?: string;
        attemptId?: string;
    };
    "model.start": {
        runId: string;
        modelCallId: string;
        modelId: string;
        providerId: string;
    };
    "model.result": {
        runId: string;
        modelCallId: string;
        modelId: string;
        providerId: string;
        usage?: TokenUsage;
        status?: "success" | "cancelled";
    };
    "model.error": {
        runId: string;
        modelCallId: string;
        modelId: string;
        providerId: string;
        status?: "error" | "cancelled";
        /** Known usage can still be billed when a call is cancelled after provider completion. */
        usage?: TokenUsage;
    };
    "run.complete": {
        runId: string;
        output: RunOutput;
    };
    "run.error": {
        runId: string;
        error: Error;
        status?: "failed" | "cancelled";
    };
    "run.stream.chunk": {
        runId: string;
        chunk: string;
    };
    "tool.call": {
        runId: string;
        toolCallId?: string;
        toolName: string;
        args: unknown;
    };
    "tool.result": {
        runId: string;
        toolCallId?: string;
        toolName: string;
        result: unknown;
        status?: "success" | "error" | "denied" | "cancelled";
        cached?: boolean;
    };
    "team.delegate": {
        runId: string;
        memberId: string;
        task: string;
    };
    "workflow.step": {
        runId: string;
        stepName: string;
        status: "start" | "done" | "error";
    };
    "voice.connected": {
        agentName: string;
    };
    "voice.audio": {
        agentName: string;
        data: Buffer;
    };
    "voice.transcript": {
        agentName: string;
        text: string;
        role: "user" | "assistant";
    };
    "voice.tool.call": {
        agentName: string;
        toolName: string;
        args: unknown;
    };
    "voice.tool.result": {
        agentName: string;
        toolName: string;
        result: string;
    };
    "voice.error": {
        agentName: string;
        error: Error;
    };
    "voice.disconnected": {
        agentName: string;
    };
    "browser.screenshot": {
        data: Buffer;
    };
    "browser.action": {
        action: unknown;
    };
    "browser.step": {
        index: number;
        action: unknown;
        pageUrl: string;
        screenshot: Buffer;
    };
    "browser.done": {
        result: string;
        success: boolean;
        steps: unknown[];
    };
    "browser.error": {
        error: Error;
    };
    "tool.approval.request": {
        requestId: string;
        toolName: string;
        args: unknown;
        agentName: string;
        runId: string;
        sessionId?: string;
        userId?: string;
        tenantId?: string;
    };
    "tool.approval.response": {
        requestId: string;
        approved: boolean;
        reason?: string;
    };
    "memory.extract": {
        sessionId: string;
        userId?: string;
        agentName: string;
    };
    "memory.error": {
        store: string;
        error: Error;
        agentName: string;
    };
    "memory.correction.recorded": {
        correctionId: string;
        agentName: string;
        field?: string;
        entityKey?: string;
        runId?: string;
    };
    "memory.learning.invalidated": {
        learningIds: string[];
        supersededBy: string;
        agentName: string;
    };
    "handoff.transfer": {
        runId: string;
        fromAgent: string;
        toAgent: string;
        reason: string;
    };
    "handoff.complete": {
        runId: string;
        chain: string[];
        finalAgent: string;
    };
    "cost.tracked": {
        runId: string;
        agentName: string;
        modelId: string;
        usage: TokenUsage;
        cost?: number;
    };
    "cache.hit": {
        agentName: string;
        input: string;
        cachedId: string;
    };
    "cache.miss": {
        agentName: string;
        input: string;
    };
    "run.cancelled": {
        runId: string;
        agentName: string;
    };
    "subagent.start": {
        runId: string;
        parentRunId: string;
        agentName: string;
        task: string;
    };
    "subagent.complete": {
        runId: string;
        parentRunId: string;
        agentName: string;
        text: string;
    };
    "subagent.error": {
        runId: string;
        parentRunId: string;
        agentName: string;
        error: Error;
    };
    "context.compacted": {
        runId: string;
        beforeTokens: number;
        afterTokens: number;
        strategy: string;
    };
    "reflection.critique": {
        runId: string;
        pass: boolean;
        score: number;
        feedback: string;
    };
};
```

Related: [`RunOutput`](/api-reference/core/agent#runoutput), [`TokenUsage`](/api-reference/core/models#tokenusage).

## AnyEventHandler

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/event-bus.ts)

```typescript theme={null}
export type AnyEventHandler = (event: string, data: unknown) => void;
```

## EventBus

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/event-bus.ts)

```typescript theme={null}
/** Observation-only lifecycle pub/sub. Use hooks, approval and execution policy for control flow.
 * Listeners run in registration order without awaiting promises; each failure is isolated.
 */
export declare class EventBus {
    static get shared(): EventBus;
    static resetShared(): void;
    constructor(options?: EventBusOptions);
    on<K extends EventKey>(event: K, handler: (data: AgentEventMap[K]) => void): this;
    once<K extends EventKey>(event: K, handler: (data: AgentEventMap[K]) => void): this;
    off<K extends EventKey>(event: K, handler: (data: AgentEventMap[K]) => void): this;
    onAny(handler: AnyEventHandler): this;
    offAny(handler: AnyEventHandler): this;
    emit<K extends EventKey>(event: K, data: AgentEventMap[K]): boolean;
    getObserverDiagnostics(): {
        failures: number;
        reported: number;
        suppressed: number;
    };
    removeAllListeners(event?: EventKey): this;
}
```

Related: [`AgentEventMap`](/api-reference/core/events#agenteventmap), [`AnyEventHandler`](/api-reference/core/events#anyeventhandler), [`EventBusOptions`](/api-reference/core/events#eventbusoptions).

## EventBusOptions

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/event-bus.ts)

```typescript theme={null}
export interface EventBusOptions {
    onObserverError?: (failure: ObserverFailure) => void | Promise<void>;
    /** Lifetime report cap. Further failures are counted, not queued. Default 100. */
    maxObserverDiagnostics?: number;
}
```

Related: [`ObserverFailure`](/api-reference/core/events#observerfailure).

## LIFECYCLE\_EVENTS

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/types.ts)

```typescript theme={null}
export declare const LIFECYCLE_EVENTS: readonly [
    "run.start",
    "run.complete",
    "run.error",
    "run.cancelled",
    "run.stream.chunk",
    "model.start",
    "model.result",
    "model.error",
    "tool.call",
    "tool.result",
    "tool.approval.request",
    "tool.approval.response",
    "team.delegate",
    "handoff.transfer",
    "handoff.complete",
    "workflow.step",
    "memory.extract",
    "memory.error",
    "memory.correction.recorded",
    "memory.learning.invalidated",
    "cost.tracked",
    "cache.hit",
    "cache.miss",
    "subagent.start",
    "subagent.complete",
    "subagent.error"
];
```

## LifecycleEvent

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/types.ts)

```typescript theme={null}
export type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number];
```

Related: [`LIFECYCLE_EVENTS`](/api-reference/core/events#lifecycle_events).

## ObserverFailure

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/events/event-bus.ts)

```typescript theme={null}
export interface ObserverFailure {
    event: string;
    kind: "named" | "any";
    /** Host-only diagnostic; never emitted back through this bus or logged implicitly. */
    error: unknown;
}
```

## Supporting types

These local shapes appear in public signatures but are not named exports of this entrypoint.

### EventKey

```typescript theme={null}
type EventKey = keyof AgentEventMap;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.