@threadplane/chatFunctionv0.3.4

normalizeEnvelopeArgs

The parent LLM may emit envelope-tool arguments in four shapes (observed in the spike across gpt-5-mini and gpt-5): the canonical {envelopes: [...]}, a singular typo {envelope: [...]}, positional keys {0: env, 1: env, ...} when the model treats the args as the array, or a flat single envelope. This pure function maps all four into a canonical envelope list.

Strict-mode tool binding (OpenAI) should eliminate the non-canonical shapes in production, but the normalizer is the safety net.

import { normalizeEnvelopeArgs } from '@threadplane/chat';

Declaration · overload 1

export declare function normalizeEnvelopeArgs(args: Record<string, unknown> | null | undefined): unknown[] | null;

Parameters

args · required
Record<string, unknown> | null | undefined

Returns

unknown[] | null