Repository navigation
GPT-OSS: render tool parameters as declared; serve changed renders cold - #2679
Closed
jonathan308 wants to merge 7 commits into
Closed
jonathan308 wants to merge 7 commits into
jonathan308 wants to merge 7 commits into
Conversation
GPT-OSS's Harmony template prints a type list as a union, a oneOf as the
union of its members and a node without a type as any. The shared schema
repair gave each such node one type (the first member's or string), so the
model was told string for numbers, booleans, objects and {}.
GPT-OSS now renders each tool's parameters from the body's own declaration
through the repair without the types it invents. A tool that this leaves as
the repair leaves it keeps its prepared tool, so a body whose tools arrive
already repaired renders byte-identically. Normalization v9 still plans the
repaired prompt, so a coordinator request whose GPT-OSS render changed is
served without the prompt cache (promptCacheSkippedToolRawSchema).
3 of 4 tasks
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…cold' into fix/gptoss-raw-tool-schema # Conflicts: # provider-swift/Sources/ProviderCore/ProviderLogger.swift # provider-swift/Sources/ProviderCore/ProviderLoop+InferenceHandler.swift # provider-swift/Tests/ProviderCoreTests/Inference/Prompting/ProductionPromptParityTests.swift
The template utility (/tokenize's applyTemplate) renders the body's tools unrepaired. For GPT-OSS it now renders each through the repair without its render types, as the served prompt does, so its count matches.
applyTemplate renders the body's tools for /tokenize. Gemma's invariant 8 (a property declared without a type renders untyped) reads the declarations; without them the utility counted STRING where the served prompt renders an empty type.
…d ids The served-cold check for another family used a GPT-OSS build id with a Qwen model type. The family is selected by build id and model type, as the Harmony template path selects it; use each family's own id.
3 tasks
Collaborator
Author
|
Closing: this branch's head (de58437) is already contained in dev. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GPT-OSS's Harmony template prints a tool parameter's
typelist as a union (string | integer), aoneOfas the union of its members and a parameter without a type asany. The schema repair that runs before every template gave each such parameter one type, the first member's orstring, so GPT-OSS was toldstringfor numbers, booleans, objects and{}. It then wrote strings ("-0.75","-4200"), JSON text, or reasoned at length about the mismatch. GPT-OSS now renders each tool from the request's own declaration and keeps the repair's type only where the declaration states one type.A request whose tools arrive already repaired (today's coordinator) renders byte-identically. A coordinator request whose GPT-OSS render changes is served without the prompt cache, as in #2651 and #2658.
Base
Stacked on #2658 (final head
4af17dfdcf, merged in by5c7797e1dd), so fold (e) has one served-cold block. This PR's changes are commits4ebb3ee07d,617338f8a0(the template utility, GPT-OSS) ande310af3e89(the template utility passes the declarations to Gemma's tool normalization, so a property declared without a type renders untyped there as in the served prompt).What changes
ToolSchemaNormalization.repairedParameters(_:writesRenderTypes:budget:): the same walk as the ingress repair. WithwritesRenderTypesfalse it writes a type only where the node states one:typelist with one concrete member (["integer","null"]) still collapses, as before;properties,items), a union whose typed members share one type (anyOf [string, null]), itsenum/constvalues, or assertions of one type family;typelist of two or more types stays a list, a union of several types,{},$refand an annotation-only node stay typeless, and a positional boolean becomes{}.ensureParameterTypesand its output are untouched.GPTOSSToolSchemaRender: for GPT-OSS only, each prepared tool whose declaration (ChatTemplateControls.declaredTools, read from the received bytes) gives a different tree with and without render types renders that declaration's parameters without them. Every other tool keeps its prepared tool. On a declaration the repair already typed, those steps have nothing to do, so the tree is the same and the prompt is unchanged. It is wired intoProviderPromptContractPipeline.normalizedInputand the prompt-token floor.GPTOSSAutoToolConstraintalready compiles each call's arguments fromdeclaredTools. With declarations as written,{}keeps free arguments and a union admits each of its members (tested).GPTOSSToolSchemaCache): chained after Gemma: render a string-first scalar union as its typed member; serve those requests cold #2658's check, on a context that still plans a cache attempt. The prompt contract staysdarkbloom-request-normalization-v9, which renders the repaired types. The request gets no scope and no receipt nonce: no lookup or ready receipt, no cached-token usage and no checkpoint write. There is a fixeddarkbloom logsline andstats.promptCacheSkippedToolRawSchemain the daemon state. No wire change. The coordinator argument accepted for Render an earlier tool call's null arguments; serve those requests cold #2651 applies unchanged: only that request loses cache routing and calibrated first-content admission./tokenize,MultiModelBatchSchedulerEngine.applyTemplate): it renders the body's tools unrepaired; for GPT-OSS it now renders each through the repair without its render types (GPTOSSToolSchemaRender.servedTools), the tools the served prompt shows, so its count matches./tokenizeutility renders the tools of the body it receives. For a raw client body that is the render of the caller's own declarations (GPT-OSS as written; Gemma 4's untyped properties with an empty type). Today's coordinator-served prompts are built from repaired declarations and match that render only once the platform forwards the caller's declarations (darkbloom-platform CI (dev): split the slow cluster runtime groups over 5 shards #1868).consumer.goApplyResolvedBuildthenbody.Current();tool_schema_state.goresolvedTools). On a repaired declaration every type is already a string and every positional node typed, soparametersWithoutRenderTypesreturns nil,renderedToolskeeps each prepared tool,changesRenderis false and nothing is served cold: the GPT-OSS prompt and its cache context are byte-for-byte as before (corpus test below). The render changes only where a body arrives with the caller's own declarations: the local API, and the coordinator once it forwards originals (darkbloom-platform CI (dev): split the slow cluster runtime groups over 5 shards #1868,DARKBLOOM_FORWARD_ORIGINAL_TOOL_SCHEMAS, default off).Test plan
GPTOSSToolSchemaRenderTests, rendering the served GPT-OSS template (Fixtures/GPTOSS/chat_template.jinja, hash-pinned) on the serving input path:type [string, integer]→string | integer,[integer, string, null]→integer | string | null,{},true,anyOf [string, number]and a description-only node →any,oneOf [integer, string]→ a union. Before, each renderedstring(numberfor the integer-first list).[string, null],[integer, null],anyOf [X, null], anenum, a mixedenum, an object,items,minimum) render exactly as before and are not served cold.parametersof a realistic tool-call schema corpus (Fixtures/GPTOSS/tool-schema-corpus.json). Forwarded repaired, each renders byte-identically and keeps its cache context. Forwarded as written, none fails to render where the repaired one renders, and some change.{}stays free (-0.75, arrays, objects,null, strings), andtype [string, integer],oneOf [integer, string]andanyOf [string, boolean]admit each member.LocalChatRequest): renders as written.[string, integer],[integer, null],true,{}andanyOf [string, null](GPT-OSS), and the same render type for{}, a description-only and an integer property (Gemma 4).ProductionPromptParityTests:gpt-oss-20b/{endpoint_messages_tool_turn, gemma_tool_turn, tools}(a{}or description-only parameter). Each is served cold, and its contract tokens are checked on its repaired tools.Components touched
Protocol / interface changes
Documentation impact
docs/architecture/inference.md(GPT-OSS render),docs/architecture/prefix-cache.md(served cold),docs/developer/test.md(corpus fixture).Changelog
changelog.d/gptoss-tool-schema-render.mdand ranpython3 scripts/changelog.py check.Before And After
flowchart TD P["prepared tools (repaired)"] --> Q{"GPT-OSS and declaration<br/>differs without render types?"} Q -- no --> S["render prepared tool (unchanged bytes)"] Q -- yes --> T["render declaration without invented types"] T --> U{"coordinator planned a cache attempt?"} U -- yes --> V["serve cold: no scope, no receipt<br/>promptCacheSkippedToolRawSchema"] U -- no --> W["serve as planned"]Red control
#2680 (draft): the same tests with the render switched back; expected to fail only at the new expectations.