Skip to content

GPT-OSS auto tool grammar: read the repair's sibling type as a render hint - #2714

Merged
jonathan308 merged 4 commits into
devfrom
fix/gptoss-auto-grammar-render-hints
Nov 24, 2026
Merged

jonathan308 merged 4 commits into
devfrom
fix/gptoss-auto-grammar-render-hints

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Under tool_choice: "auto", GPT-OSS's call grammar (GPTOSSAutoToolConstraint) compiles each tool's arguments from its declaration. Where the schema repair writes a type beside a not of that type ({"not": {"type": "string"}, "type": "string"}), the grammar held the argument to that type, which the declaration refuses. The call parser and the strict check already read such a sibling type as a render hint (QwenParserLiteralReading.rendersSiblingType, #2640); the grammar now does too, and keeps null where the node is marked nullable.

The red control's CI shows that unions and mixed enums beside the render type were already compiled to free arguments, so OR-FUZZ G1's "-4200" does not come from this grammar. The new tests pin that those shapes stay free.

Base

Stacked on #2689 (939db0b3d5). Commits c1f154c7d8, ff4f9d67d9 (a hinted node marked nullable keeps admitting null), 713d506429 (tests: a contradicted enum, a not of the render type) and 084adbfbdf (changelog and architecture note state what changes).

What changes

  • GPTOSSAutoToolGrammar.compiledArguments compiles each declaration after withoutRenderHintTypes. That pass drops a node's type exactly where rendersSiblingType holds: beside an anyOf / oneOf that names it among its branches, a mixed enum, a not of that type, or an if/then/else typed otherwise. It walks properties, patternProperties, items, prefixItems, additionalProperties, the unions, not/if/then/else and $defs/definitions, to the compiler's depth.
  • A hinted node marked nullable: true keeps admitting null, as the strict check reads it: once the hint is dropped, a null branch is added to its anyOf / oneOf and null to its enum where they lack one.
  • The node is then compiled or widened as written. A not of the render type is no longer held to that type; unions and mixed enums stay free, as before.
  • Unchanged:
    • a declaration without such a type (the pass returns it as is);
    • Pydantic's nullable unions (the existing widening already drops their render type, so the compiled result is identical);
    • forced choices (required/named compile the request's tools, not this path);
    • the prompt;
    • validation.

Test plan

  • CI (dev) on this head.
  • New GPTOSSAutoToolRenderHintTests:
    • {anyOf|oneOf: [string, integer], type: string} admits -4200 and "-4200";
    • a mixed enum with type: string admits -1 and "inherit";
    • an enum of integers beside type: string admits 2; {not: {type: string}, type: string} admits 5 and true;
    • a hinted node marked nullable (two-branch anyOf, one-branch oneOf, mixed enum) admits null and its typed members;
    • compiled exactly as before: weather, time, zod read, inlined booking, anyOf without a sibling, plain integer, nullable type list, a consistent sibling (type: object beside typeless anyOf branches) and Pydantic's routed nullable unions. The pass returns the declaration unchanged (except the nullable unions), and the compiled arguments describe identically to the previous exact-or-widened result;
    • forced choices: required compiles the request's tools exactly as ToolConstraintSchemaCompiler.compile does.
  • Red control: Red control for #2714: tests without the change (do not merge) #2715 (draft). Its pass keeps the hint types. CI (dev) 45449915283 on its previous head failed at "a not of the render type admits values of every other type" (plus bothMembersCompleteTheKeyPreludeAndReleaseOnlyAfterTheirOwnersExit in an unrelated suite); the union, nullable and enum tests pass on both, as these shapes were already free.
  • Merge check: no files in common with GPT-OSS: return a whole declared call written as the answer or inside the analysis #2694 (4f2c4b9901) or GPT-OSS call recovery off by default (do not merge unless the #2694 gate fails) #2700 (418e5964e1); git merge-tree is clean with both.
  • Refactor pass: no change justified.

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • No protocol/interface changes

Documentation impact

  • Canonical documentation updated: docs/architecture/inference.md (GPT-OSS auto tool calls).

Changelog

  • Added changelog.d/gptoss-auto-grammar-render-hints.md; python3 scripts/changelog.py check passes.

Before And After

flowchart LR
  D["declared: anyOf [string, integer] + type string (render hint)"] --> B["Before: grammar compiles type string<br/>model writes &quot;-4200&quot;"]
  D --> P["After: withoutRenderHintTypes drops the hint"] --> A["grammar compiles or widens the union<br/>-4200 and &quot;-4200&quot; both admitted"]
Loading

… hint

The auto grammar compiled the type the schema repair writes beside a union
naming one of its branches, a mixed enum, a not or an if as a hard type, so
a string-or-integer argument could only be written as a string. Drop that
type before compiling (QwenParserLiteralReading.rendersSiblingType, the rule
the call parser and the strict check already read). Declarations without
such a type compile exactly as before; forced choices, the prompt and
validation are unchanged.
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 24, 2026 5:58pm UTC
darkbloom-status Ready Ready Preview Nov 24, 2026 5:58pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 24, 2026 5:58pm UTC

Request Review

@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
@github-actions github-actions Bot removed the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
…ing null

The strict check admits null at a node marked nullable even when its type
is a render hint. Once the hint is dropped, carry that null in the node's
union or enum so the grammar admits it too.
CI on the red control shows the previous grammar already left unions and
mixed enums beside the render type free; only a not of the render type was
held to it. Say so in the changelog and the architecture note.
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
@github-actions github-actions Bot removed the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Nov 24, 2026
@jonathan308
jonathan308 changed the base branch from perf/sdk-pin-m9 to dev November 24, 2026 18:51
@jonathan308
jonathan308 merged commit a342584 into dev Nov 24, 2026
27 checks passed

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — 084adbfb Deployed Nov 24, 2026 by vercel[bot]
Preview – d-inference-landing — 084adbfb Deployed Nov 24, 2026 by vercel[bot]
Preview – darkbloom-status — 084adbfb Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant