Skip to content
5 min read · 935 words

@nhtio/adk/exceptions

Core ADK exception classes and reusable runtime error constructors.

Every exception has a stable E_* code. The fatal flag on each code controls whether it throws synchronously (programming error — no recovery path) or is emitted on the observability error bus (runtime failure — run() still resolves).

Classes

ClassDescription
ValidationExceptionThrown when input fails schema validation.

Artifacts

Exceptions from spool and media artifact construction. Fatal — wrap-site validation that the supplied value implements the required reader interface.

VariableDescription
E_INVALID_INITIAL_MEDIA_VALUEThrown when a Media is initialised with a value that fails schema validation.
E_NOT_A_MEDIA_READERThrown when a Media is constructed with a value that does not implement the MediaReader interface.
E_NOT_A_SPOOL_READERThrown when a @nhtio/adk!SpooledArtifact is constructed with a value that does not implement the @nhtio/adk!SpoolReader interface.

Dispatch

Exceptions from the dispatch loop and its executor. A mix of fatal (programming errors) and non-fatal (runtime failures that nack the dispatch). The loop terminates as 'ack', 'nack', or 'aborted' — inspect dispatchEnd.status to classify.

VariableDescription
E_INVALID_LLM_DISPATCH_INPUTThrown when @nhtio/adk!DispatchRunner.dispatch receives an input that fails schema validation.
E_INVALID_LLM_EXECUTION_CONTEXTThrown when @nhtio/adk!DispatchContext is constructed with a value that fails schema validation.
E_LLM_EXECUTION_ALREADY_SIGNALLEDThrown when @nhtio/adk!DispatchContext.ack or @nhtio/adk!DispatchContext.nack is called on a context that has already been signalled.
E_LLM_EXECUTION_EXECUTOR_ERROREmitted (via the observability error hook) and re-thrown when the user-supplied executor callback throws during @nhtio/adk!DispatchRunner.dispatch.
E_LLM_EXECUTION_GATE_NOT_SUPPORTEDThrown (as a rejection reason) when @nhtio/adk!DispatchContext.waitFor is called on a standalone context that was constructed without a waitFor function.

Gates

Exceptions from @nhtio/adk!TurnGate construction and settlement. All four settlement outcomes (resolved, invalid-resolution, aborted, timed-out) also emit turnGateClosed on the observability bus.

VariableDescription
E_INVALID_INITIAL_TURN_GATE_VALUEThrown when a @nhtio/adk!TurnGate is constructed with a value that fails schema validation.
E_INVALID_TURN_GATE_RESOLUTIONThrown synchronously in the caller's context when @nhtio/adk!TurnGate.resolve is called with a value that fails the gate's schema.
E_TURN_GATE_ABORTEDThrown (as a rejection reason) when a @nhtio/adk!TurnGate is aborted — either because the turn's AbortSignal fired or because @nhtio/adk!TurnGate.abort was called directly.
E_TURN_GATE_TIMEOUTThrown (as a rejection reason) when a @nhtio/adk!TurnGate times out before being resolved.

Pipelines

Non-fatal pipeline errors emitted on the observability error bus when middleware throws or a pipeline short-circuits. run() resolves; turnEnd still fires.

VariableDescription
E_DISPATCH_PIPELINE_ERROREmitted (via the observability error hook) and re-thrown when a non-abort error propagates out of the input or output middleware pipeline during @nhtio/adk!DispatchRunner.dispatch.
E_INPUT_PIPELINE_ERROREmitted (via the error event) when a non-abort error propagates out of the input middleware pipeline during @nhtio/adk!TurnRunner.run.
E_OUTPUT_PIPELINE_ERROREmitted (via the error event) when a non-abort error propagates out of the output middleware pipeline during @nhtio/adk!TurnRunner.run.
E_PIPELINE_SHORT_CIRCUITEDEmitted (via the error event) when a middleware pipeline resolves without reaching its terminal handler and without the turn being aborted. Indicates that some middleware returned without calling next and without signalling a deliberate refusal via the turn's abort controller.

Primitive Validation

Fatal exceptions thrown at construction time when a primitive (@nhtio/adk!Message, @nhtio/adk!Memory, @nhtio/adk!Thought, @nhtio/adk!ToolCall, @nhtio/adk!Retrievable, @nhtio/adk!Identity, @nhtio/adk!Registry) receives an invalid initial value. If a primitive constructed, it is valid.

VariableDescription
E_INVALID_INITIAL_IDENTITY_VALUEThrown when an @nhtio/adk!Identity is initialised with a value that fails schema validation.
E_INVALID_INITIAL_MEMORY_VALUEThrown when a @nhtio/adk!Memory is initialised with a value that fails schema validation.
E_INVALID_INITIAL_MESSAGE_VALUEThrown when a @nhtio/adk!Message is initialised with a value that fails schema validation.
E_INVALID_INITIAL_REGISTRY_VALUEThrown when a registry is initialised with a value that is defined but not a plain object.
E_INVALID_INITIAL_RETRIEVABLE_VALUEThrown when a @nhtio/adk!Retrievable is initialised with a value that fails schema validation.
E_INVALID_INITIAL_THOUGHT_VALUEThrown when a @nhtio/adk!Thought is initialised with a value that fails schema validation.
E_INVALID_INITIAL_TOOL_CALL_VALUEThrown when a @nhtio/adk!ToolCall is initialised with a value that fails schema validation.

Tools

Exceptions from tool construction, registration, argument validation, and handler execution. E_TOOL_DOWNSTREAM_ERROR wraps handler throws — the original error is on .cause.

VariableDescription
E_INVALID_INITIAL_TOOL_VALUEThrown when a @nhtio/adk!Tool is constructed with a value that fails schema validation.
E_INVALID_TOOL_ARGSThrown synchronously when @nhtio/adk!Tool.validate is called with arguments that fail the tool's input schema.
E_TOOL_ALREADY_REGISTEREDThrown when @nhtio/adk!ToolRegistry.register is called for a tool name that is already registered and overwrite is not true.
E_TOOL_DOWNSTREAM_ERRORThrown (as a rejection reason) when a @nhtio/adk!Tool's handler throws during execution.

Turn Input Validation

Exceptions thrown when the raw turn context supplied to runner.run() fails validation. Fatal and synchronous — thrown before turnStart is emitted.

VariableDescription
E_INVALID_TURN_CONTEXTThrown by @nhtio/adk!TurnRunner when the @nhtio/adk!TurnContext supplied to run fails schema validation.

Turn Runner Construction

Exceptions thrown when a @nhtio/adk!TurnRunner is misconfigured at construction time. Fatal — a misconfigured runner cannot execute turns.

VariableDescription
E_INVALID_TURN_RUNNER_CONFIGThrown by @nhtio/adk!TurnRunner when the supplied config object fails schema validation at construction time.