Skip to content

GPT-OSS: return a whole declared call written as the answer or inside the analysis - #2694

Merged
jonathan308 merged 4 commits into
devfrom
fix/gptoss-tool-call-recovery
Nov 24, 2026
Merged

jonathan308 merged 4 commits into
devfrom
fix/gptoss-tool-call-recovery

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

For an auto GPT-OSS request that declares tools, the model sometimes writes the call in a form the Harmony handler doesn't return as a call:

  • after the loop guard ends its analysis, it answers with only the call's JSON arguments and no recipient; or
  • it ends an analysis it never closes with a complete to=functions.<name> frame.

GPTOSSToolCallRecovery now returns these as calls, under strict conditions:

  1. After a loop-guard exit: the answer is held to the end of generation. It's returned as the call only if all of these hold:
    • it is one final (or recipientless commentary) message;
    • it holds a single JSON object;
    • exactly one declared tool admits that object: every key is a declared property, and ToolConstraintValidation finds nothing the declaration rules out.
  2. An analysis that is still open and ends with a complete frame naming a declared function, with one JSON object its schema holds, returns that call. Partial frames never do.

Unchanged: anything else, answers cut at the limit or by length, and responses that already hold a call. The rendered prompt doesn't change. DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY (0/off/false/no) turns it off; it is on by default and forwarded to the LaunchAgent (test theSwitchReachesTheDaemon). #2700 holds the same change with the default off.

Stacked on #2689 (the pin to SDK main e7918994a7); the base moves to dev once that lands. No SDK change.

Linked issue

None.

Test plan

  • CI (dev) on this head: GPTOSSToolCallRecoveryTests.
    • Recovered: three real argument-only answers (a null argument, a string, a quoted product name) and recipientless commentary.
    • Left as written:
      • two tools match;
      • extra text or code fences;
      • arrays, two objects, {};
      • an undeclared key, or a value the schema refuses;
      • a plain answer, or no loop-guard exit;
      • length/limit cut, an existing call;
      • tool_choice none/required, other models, the switch off;
      • partial, undeclared, refused or YAML frames, and frames in a closed analysis.
    • Scheduler: streamed and complete responses.
  • Red control Red control for #2694: tests without the change (do not merge) #2695 (draft, df05929921): its recovery holds nothing and returns no call, so exactly these fail:
    • anAnswerThatIsOneToolsArgumentsLeavesAsThatCall (both cases);
    • aRecipientlessCommentaryAnswerAlsoLeavesAsTheCall;
    • anAnswerCutAtTheLimitOrWithACallIsNotRead (nothing is held, so a call does not release held text before itself);
    • aCompleteFrameEndingTheOpenAnalysisLeavesAsTheCall;
    • theSchedulerReturnsTheRecoveredCalls (streamed and complete).
  • scripts/changelog.py check, scripts/docs-impact-check.py.

Refactor pass: no change justified.

Components touched

  • provider-swift (Swift CLI)
  • native runtime / MLX
  • landing (Next.js)
  • enclave (Swift)
  • CI / provider release
  • docs

Protocol / interface changes

  • No protocol/interface changes
  • Yes — one new provider environment variable, DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY (on by default); no wire or release change.

Documentation impact

  • Canonical documentation updated: docs/reference/configuration.md; changelog fragment changelog.d/gptoss-tool-call-recovery.md.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… the analysis

For an auto request that declares tools, GPT-OSS sometimes answers after
the loop guard ended its analysis with the call's JSON arguments and no
recipient, or ends an analysis it never closes with a complete call frame,
and the Harmony parser returns no call. GPTOSSToolCallRecovery holds the
answer after the loop guard's exit to the end of generation and returns it
as a call when it is one final (or recipientless commentary) message
holding a single JSON object that exactly one declared tool admits: every
key a declared property and the caller's schema holding
(ToolConstraintValidation.breaksDeclaration). A still-open analysis that
ends with to=functions.<declared>, its header, <|message|> and one JSON
object the schema holds returns that call. Anything else, an answer cut at
the limit, or a response that has a call, leaves as before. No rendered
prompt changes.

DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY=0|off|false|no turns it off.
@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 7:10pm UTC
darkbloom-status Ready Ready Preview Nov 24, 2026 7:10pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 24, 2026 7:10pm UTC

Request Review

DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY joins LaunchAgent.inferencePassthroughEnvKeys,
so its off word reaches a provider run by launchd, as the other GPT-OSS
switches do; tested with the passthrough. The scheduler routes through
the recovery with optional chaining.
…ice serves

A required choice refuses an anyOf parameter before any recovery is
made, so the check now declares a plain integer parameter.
@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 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:52
The configuration reference gains rows on both sides at the same place;
the merge keeps both. No code change.
@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 merged commit dfa97df into dev Nov 24, 2026
27 checks passed

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — c0131a76 Deployed Nov 24, 2026 by vercel[bot]
Preview – d-inference-landing — c0131a76 Deployed Nov 24, 2026 by vercel[bot]
Preview – darkbloom-status — c0131a76 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