Skip to content

fix(provider): harden GPT-OSS Harmony requests - #703

Merged
Gajesh2007 merged 1 commit into
masterfrom
fix/gptoss-multi-system
Aug 25, 2026
Merged

Gajesh2007 merged 1 commit into
masterfrom
fix/gptoss-multi-system

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • preserve all text-only system instructions by folding them into one leading Harmony instruction instead of dropping later system turns
  • normalize GPT-OSS tool histories before generic validation and reject ambiguous call/result IDs without silently duplicating or losing results
  • temporarily render GPT-OSS reasoning_effort: high as medium to avoid the observed 300-second upstream timeout; other models and effort values remain unchanged

Before

flowchart LR
    A[OpenAI chat request] --> B[ProviderLoop decode]
    B --> C[Generic tool-history validation]
    C --> D[GPTOSSHarmonyTemplateFix]
    D --> E[Harmony Jinja template]
    E --> F[Only first system turn retained]
    B --> G[reasoning_effort high passed through]
    G --> E
    E --> H[High-effort runaway can exceed 300s]
Loading

After

flowchart LR
    A[OpenAI chat request] --> B[ProviderLoop decode]
    B --> C[ProviderPromptContractPipeline]
    C --> D[LeadingSystemMessageNormalizer]
    D --> E[GPT-OSS tool-history normalization]
    E --> F[Generic validation]
    F --> G[Harmony Jinja template]
    G --> H[All text system instructions retained]
    C --> I{GPT-OSS and high?}
    I -->|yes| J[Render as medium]
    I -->|no| K[Preserve requested effort]
    J --> G
    K --> G
Loading

Test plan

  • swift test — 2,160 tests passed
  • DARKBLOOM_LIVE_MLX_TESTS=1 swift test --filter ReasoningEffortLiveTests — real GPT-OSS template and generation passed
  • targeted GPT-OSS policy, Jinja rendering, multi-system, and tool-history regressions passed
  • repository pre-push checks passed

Made with Cursor


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Preserve every system instruction and reject ambiguous tool histories while serving high reasoning effort as medium to avoid upstream timeouts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview Aug 25, 2026 1:40am
d-inference-console-ui-dev Ready Ready Preview Aug 25, 2026 1:40am
d-inference-landing Ready Ready Preview Aug 25, 2026 1:40am

Request Review

@Gajesh2007
Gajesh2007 merged commit 545345e into master Aug 25, 2026
14 of 17 checks passed
@Gajesh2007
Gajesh2007 deleted the fix/gptoss-multi-system branch August 25, 2026 01:58
jonathan308 added a commit that referenced this pull request Nov 8, 2026
…ony level, as the coordinator plans them

B-J2-1's last two families. #1909 kept Gemma 4 and GPT-OSS on the
prompts they rendered before, because the coordinator's prompt sidecar
planned those. The sidecar in darkbloom-platform#721 now plans them
like the other families, from a copy of these tables, so the provider
renders the same:

- Gemma 4 (gemma4, gemma4_text, gemma4_vision) and DiffusionGemma take
  an effort as their thinking switch (ReasoningEffortPolicy
  .effortSetsThinkingSwitch, ReasoningEffort.oneDepthThinking): on for
  every effort but none, which turns it off. An explicit switch wins,
  and no effort keeps the template's default.
- GPT-OSS renders each effort at the nearest Harmony level, a new table
  ReasoningEffort.harmonyLevel (none, minimal and low as low; medium;
  high, xhigh and max as high), thinking or not (templateEffort).
  GPTOSSHarmonyTemplateFix.effectiveReasoningEffort, the high->medium of
  #703, goes: the coordinator keeps OpenRouter's traffic at medium,
  service accounts only, so a direct caller's high renders high.

ReasoningEffort.swift's notes name the coordinator's copies and the
agreement test. Two tests that asserted the old GPT-OSS medium
(GPTOSSHarmonyTemplateFixesTests, BenchmarkProductionInputTests) now
assert high.

The fixtures are darkbloom-platform 92a208a7da5c1020c5a19ac4c29ba302d34b0838,
byte for byte:
  production_vectors.json        0bba2b663a1bfe112a08230ac15f7e57d9dfdbb0302e26c0e4884cc2d7ee05f9
  reasoning_effort_vectors.json  6ca08c3e1db6d5fdd906cf76b818d6d60d212fa19cfd3bea10bcbafecec16aa4
  native_reasoning_vectors.json  c4d496f6a6b7e4fdcaa9d59debf8f40c16a1cc1d86e0e76f8aadb916922ea9d2

Tests: the red commit (7079a37) failed in CI exactly as planned.
Shard 1 had 36 issues: the agreement test on 35 cases (16 Gemma 4, 19
GPT-OSS) and the native vector. Its prompt-parity gate
(verify-prompt-parity.sh) failed on the three Gemma 4 reasoning_effort
cases. Shard 2 had 75 issues: Gemma 4 one-depth 36, GPT-OSS levels 20,
GPT-OSS template context 14, table rule 5. Locally, with Xcode 27.2 on
CPU only, these pass:
CachePromptParityTests, ReasoningEffortValuesTests, templateContext*,
GPTOSSHarmonyTemplateFixesTests, BenchmarkProductionInputTests,
DiffusionGemmaReasoningControlTests, PromptDateRenderingTests,
Qwen4ReasoningEffortValidationTests, InboundDecodeTests,
NemotronSuperPromptContractTests and GLM5NextPromptPolicyTests. So does
ProductionPromptParityTests (PROMPT_PARITY_REQUIRED=1, the manifests'
artifacts): Swift and the platform's Rust render every case of the
seven production models token for token. EngineV2VisionRoutingTests
needs a Metal device, so it is left to CI.

Docs: inference.md (the family table; the pending marker goes) and
test.md (the agreement fixture and its generator), plus a changelog
fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 9, 2026
…s live, in that order

#1916's review, condition C1. This PR moves #703's high->medium rule out
of the provider: GPT-OSS now renders high for high, xhigh and max.
OpenRouter's GPT-OSS stays at medium only through darkbloom-platform#721's
service cap (ApplyServiceEffortCap). A Mac that runs this change before
the cap is live renders OpenRouter's high as high, which #703 capped to
avoid upstream timeouts. Merging to dev is safe; releasing isn't, until
the cap ships.

The changelog fragment and inference.md now say so, with the order,
each step on the owner's go:
1. tag a provider release with this change, without publishing it to
   auto-update;
2. snapshot that tag into darkbloom-platform#721;
3. deploy #721;
4. then let Macs update.
The GPT-OSS row of the effort table no longer says the coordinator caps
OpenRouter's traffic as if it already did: it names #721's cap and the
condition.

Also the review's N2: the production prompt vectors carry one effort case
per model, reasoning_effort "medium" (checked against the fixture: 7
models, 22 cases each, one with an effort). They pin Gemma 4's switch;
GPT-OSS's levels are bound by the agreement fixture. inference.md said
the vectors carry both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference — c30358b6 Deployed Aug 25, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — c30358b6 Deployed Aug 25, 2026 by vercel[bot]
benchmarks — c30358b6 Deployed Aug 25, 2026 by Gajesh2007 via E2E Benchmarks #398
Preview – d-inference-landing — c30358b6 Deployed Aug 25, 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.

2 participants