Skip to content
1 min read · 295 words

@nhtio/adk/batteries/llm/openai_chat_completions/exceptions

Battery-scoped exception constructors for OpenAI Chat Completions adapter failures.

Remarks

Battery-scoped exception classes for the OpenAI Chat Completions adapter. These exceptions are owned by the battery (not the ADK core) and are minted via createException from @nhtio/adk/factories. Re-exported from the battery's barrel.

Variables

VariableDescription
E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONSThrown when the resolved adapter options (constructor, executor overrides, or per-dispatch stash.openaiChatCompletions) fail validation against openAIChatCompletionsOptionsSchema.
E_OPENAI_CHAT_COMPLETIONS_CONTEXT_OVERFLOWThrown when the total token weight of the resolved request exceeds contextWindow. Only raised when tokenEncoding is non-null. Carries { total, contextWindow, tokenEncoding, perBucket } in the message so middleware can target shedding.
E_OPENAI_CHAT_COMPLETIONS_HTTP_ERRORThrown when the upstream Chat Completions endpoint returns a non-2xx response. Non-fatal — surfaced via ctx.nack(...) so middleware can decide retry / fail.
E_OPENAI_CHAT_COMPLETIONS_INVALID_TOOL_CALL_ARGSRaised when a tool-call's arguments string emitted by the model is not a JSON object — either non-parseable JSON, or parseable JSON whose root is not an object (e.g. a bare string, number, array, or null).
E_OPENAI_CHAT_COMPLETIONS_REQUEST_TIMEOUTThrown when the initial request handshake (TCP connect, TLS, response headers) does not complete before requestTimeoutMs. Non-fatal — surfaced via ctx.nack(...). Eligible for retry on the same footing as a retriable 5xx.
E_OPENAI_CHAT_COMPLETIONS_STREAM_ERRORThrown when the SSE stream emits a malformed chunk or the transport throws mid-stream. Non-fatal — surfaced via ctx.nack(...).
E_OPENAI_CHAT_COMPLETIONS_STREAM_STALLEDThrown when the SSE stream goes silent for longer than streamIdleTimeoutMs. Non-fatal — surfaced via ctx.nack(...) with partial-state details so middleware can recover.
E_UNSUPPORTED_MEDIA_MODALITYRaised when a @nhtio/adk!Media instance whose modality cannot be natively represented in the OpenAI Chat Completions wire format reaches the adapter under unsupportedMediaPolicy: 'throw'.