Skip to content
1 min read · 140 words

Variable: E_OPENAI_CHAT_COMPLETIONS_INVALID_TOOL_CALL_ARGS ​

ts
const E_OPENAI_CHAT_COMPLETIONS_INVALID_TOOL_CALL_ARGS: CreatedException<
  [string, string]
>;

Defined in: src/batteries/llm/openai_chat_completions/exceptions.ts:108

Raised 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).

Remarks ​

Non-fatal. The adapter does NOT throw this — it instantiates it inside executeAndPersistToolCall, pulls .message into a @nhtio/adk!Tokenizable, and persists a ToolCall record with isError: true. The model sees the formatted message in the next iteration's history and can self-correct. Consumers introspecting persisted error results can match on the E_OPENAI_CHAT_COMPLETIONS_INVALID_TOOL_CALL_ARGS code substring.

Printf args: [reasonHeadline, rawArgs].

  • reasonHeadline — short reason such as 'are not valid JSON' or 'must be a JSON object; received array'.
  • rawArgs — the raw arguments string the model emitted, echoed back verbatim so the model can see what it sent.