Skip to content

unsupportedToolSchemaKeywords not applied for OpenAI-completions providers (Fireworks) #75467

@bobrenze-bot

Description

@bobrenze-bot

Problem

getCompat(model) in openai-transport-stream-aPa0aR5w.js builds a new compat object from model.compat but only copies specific known fields — it does NOT include unsupportedToolSchemaKeywords. So even when a model's catalog entry has compat.unsupportedToolSchemaKeywords: ["not"], the keyword is stripped from the compat object before it reaches the tool schema builder.

Call Chain Issue

The downstream call chain is:

  1. buildOpenAICompletionsParams calls convertTools(context.tools, compat, model) — here compat is the result of getCompat(model) which is missing unsupportedToolSchemaKeywords
  2. convertTools calls normalizeOpenAIStrictToolParameters(tool.parameters, strict === true) — no compat passed
  3. normalizeOpenAIStrictToolParameters calls normalizeToolParameterSchema(schema ?? {}) — no options passed
  4. normalizeToolParameterSchema calls resolveUnsupportedToolSchemaKeywords(options?.modelCompat) — gets undefined, returns empty Set, no keywords stripped

Symptom

Fireworks (kimi-k2p5-turbo) returns 400 JSON Schema not supported: could not understand the instance {'not': {}} on every request, because {"not":{}} (from a Zod z.never() in a tool schema) is never stripped despite compat.unsupportedToolSchemaKeywords: ["not"] being in the catalog.

Impact

  • attempt-dispatch latency: 11-22s (failing + fallback) vs expected 3-4s
  • Fireworks model completely non-functional for tool use

Solution

Thread model.compat directly (not the result of getCompat()) through the call chain:

// In normalizeStrictOpenAIJsonSchema — add modelCompat param and pass to normalizeToolParameterSchema
function normalizeStrictOpenAIJsonSchema(schema, modelCompat) {
    return normalizeStrictOpenAIJsonSchemaRecursive(normalizeToolParameterSchema(schema ?? {}, { modelCompat }), 0);
}

// In normalizeOpenAIStrictToolParameters — add modelCompat param and pass through
function normalizeOpenAIStrictToolParameters(schema, strict, modelCompat) {
    if (!strict) return normalizeToolParameterSchema(schema ?? {}, { modelCompat });
    return normalizeStrictOpenAIJsonSchema(schema, modelCompat);
}

// In convertResponsesTools — pass model.compat (line ~1030)
parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)

// In convertTools — pass model.compat (line ~2016)
parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat),

Note: model.compat is passed directly (not the output of getCompat(model)) because extractModelCompat() handles both shapes — if passed an object without a compat key, it returns the object itself as the compat.

Additional Change Required

The built-in Fireworks catalog entry for kimi-k2p5-turbo needs compat.unsupportedToolSchemaKeywords: ["not"] added (in the source that compiles to provider-catalog-BV3NRbEh.js):

{
    "id": "accounts/fireworks/routers/kimi-k2p5-turbo",
    // ... existing fields ...
    "compat": {
        "unsupportedToolSchemaKeywords": ["not"]
    }
}

Verification

After applying both patches, Fireworks requests succeed and attempt-dispatch latency dropped from 11-22s to 3-4s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions