From 81184318f54fe25de796eefcb928cabf4d919966 Mon Sep 17 00:00:00 2001 From: Jonathan Spangler Date: Tue, 24 Nov 2026 08:39:09 -0800 Subject: [PATCH] GPT-OSS call recovery: off by default DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY set to 1, on, true or yes turns it on; unset keeps calls as the Harmony parser returns them. --- changelog.d/gptoss-tool-call-recovery.md | 4 ++-- docs/reference/configuration.md | 2 +- .../Inference/Tools/GPTOSSToolCallRecovery.swift | 7 ++++--- .../Sources/ProviderCore/Service/LaunchAgent.swift | 5 ++--- .../Inference/Tools/GPTOSSToolCallRecoveryTests.swift | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/changelog.d/gptoss-tool-call-recovery.md b/changelog.d/gptoss-tool-call-recovery.md index e4486f78ef..fb6e95472f 100644 --- a/changelog.d/gptoss-tool-call-recovery.md +++ b/changelog.d/gptoss-tool-call-recovery.md @@ -8,5 +8,5 @@ declared property, the schema holding), and such a frame when it is complete, names a declared function and its arguments hold. Anything else is returned as before. No rendered prompt changes. -- `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY`: `0`, `off`, `false` or `no` turns it - off. +- Off by default: `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY` set to `1`, `on`, + `true` or `yes` turns it on. diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 1b3107bf17..a2fdacb026 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -630,7 +630,7 @@ and rollback are defined in the [provider configuration reference](../provider/c | `DARKBLOOM_STRICT_TOOL_GRAMMAR_ALL_TOOLS` | `on`, `1`, `true`, `yes` enable (trimmed, case-insensitive) | off | `provider-swift/Sources/ProviderCore/Inference/Tools/QwenStrictToolGrammar.swift` (`allTools`) | Also constrains the calls of requests that declare no `strict` function. Forwarded to the LaunchAgent. | | `DARKBLOOM_GLM_REFERENCE_TOOL_HISTORY` | `0`, `off`, `false`, `no` disable (trimmed, case-insensitive) | on | `provider-swift/Sources/ProviderCore/Inference/Prompting/GLM5NextPromptPolicy.swift` (`referenceToolHistoryEnabled`) | GLM-5.3-Flash serves history tool-call arguments and tool schemas in shapes vLLM and the OpenAI API accept: a repeated argument key keeps its last value, a number that no JSON value holds exactly is read as a JSON value holds it, and GLM tool-call markers in argument keys and strings are text. Off refuses them as `invalid tool arguments`, `invalid tool schema` and `native delimiter in history`. Requests accepted before render identically. Read once per process; forwarded to the LaunchAgent. See [GLM-5.3-Flash](../architecture/inference.md). | | `DARKBLOOM_QWEN_CALL_END_GUARD` | `0`, `off`, `false`, `no` disable (trimmed, case-insensitive) | on | `provider-swift/Sources/ProviderCore/Inference/QwenCallEndGuard.swift` (`enabled`) | Qwen 3.5-family text requests with a `required` or named `tool_choice` admit no stop token while a call frame is open, on one Mac that runs token constraints; everything else is sampled as without it. See [no end of turn inside a Qwen call frame](../architecture/inference.md#no-end-of-turn-inside-a-qwen-call-frame). Forwarded to the LaunchAgent. | -| `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY` | `0`, `off`, `false`, `no` disable (trimmed, case-insensitive) | on | `provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift` (`enabled`) | GPT-OSS `auto` requests with tools: an answer after the loop guard ended the analysis that is a single JSON object exactly one declared tool admits, or a complete declared call frame ending an analysis that never closed, is returned as that call. Anything else is returned as before. Read once per process; forwarded to the LaunchAgent. | +| `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY` | `1`, `on`, `true`, `yes` enable (trimmed, case-insensitive) | off | `provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift` (`enabled`) | GPT-OSS `auto` requests with tools: an answer after the loop guard ended the analysis that is a single JSON object exactly one declared tool admits, or a complete declared call frame ending an analysis that never closed, is returned as that call. Anything else is returned as before. Read once per process; forwarded to the LaunchAgent. | | `DARKBLOOM_MEDIA_ON_EVERY_ROLE` | `0`, `off`, `false`, `no` disable (trimmed, case-insensitive) | on | `provider-swift/Sources/ProviderCore/Inference/Vision/MediaIngest.swift` (`everyRoleEnabled`) | Images and videos in system, assistant and tool messages are kept and placed by the model's chat template on one Mac and on GLM tensor-parallel pairs; media the template refuses or leaves without a placeholder is a 400 `media_role_not_rendered`. Off restores the family's previous media handling. Inkling and Diffusion Gemma still keep tool-result media on their native paths. Read once per process; forwarded to the LaunchAgent. | | `DARKBLOOM_PREFILL_DEADLINE_MODE` | exactly `off` disables; any other value enforces | `enforce` | `provider-swift/Sources/ProviderCore/Inference/Engine/PrefillDeadlineMode.swift` (`PrefillDeadlineMode.resolve`) | Prefill-deadline admission on the provider. Read only when `[backend] prefill_deadline_mode` is absent from `provider.toml`; that key takes precedence. | | `DARKBLOOM_TTFT_ADMISSION_FIXES` | `0`, `false`, `off`, `no` disable (trimmed, case-insensitive) | on | `provider-swift/Sources/ProviderCore/Inference/Performance/Deadline/AdmissionRateEstimators.swift` (`DeadlineAdmissionFixes`) | Deadline-admission estimator corrections: per-batch decode charging, anchored isolated-prefill rate, newest-observation freshness, a probe that re-measures stale isolated-prefill evidence after three refusals it explains. Off restores the previous estimators and turns that probe off too. Forwarded to the launchd provider job. | diff --git a/provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift b/provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift index 99e8d38bf1..7ca8319a73 100644 --- a/provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift +++ b/provider-swift/Sources/ProviderCore/Inference/Tools/GPTOSSToolCallRecovery.swift @@ -26,14 +26,15 @@ import MLXLMServer /// /// vLLM returns both as text (or nothing). Neither changes a rendered prompt. /// -/// `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY`: unset or any other value keeps it on; -/// `0`, `off`, `false` or `no` turns it off. Read once per process. +/// `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY`: `1`, `on`, `true` or `yes` turns it +/// on; unset or any other value keeps it off. Read once per process. struct GPTOSSToolCallRecovery: Sendable { static let environmentKey = "DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY" static let enabled = isEnabled(environment: ProcessInfo.processInfo.environment) static func isEnabled(environment: [String: String]) -> Bool { - !ToolOutputLeniencySwitch.isOff(environment[environmentKey]) + ["1", "on", "true", "yes"].contains( + environment[environmentKey]?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() ?? "") } /// The most visible text kept for the analysis check: a frame is a header diff --git a/provider-swift/Sources/ProviderCore/Service/LaunchAgent.swift b/provider-swift/Sources/ProviderCore/Service/LaunchAgent.swift index 4503bbe86b..5ba7ae74b2 100644 --- a/provider-swift/Sources/ProviderCore/Service/LaunchAgent.swift +++ b/provider-swift/Sources/ProviderCore/Service/LaunchAgent.swift @@ -515,9 +515,8 @@ public enum LaunchAgent: Sendable { /// default; an off word (`off`, `false`, `0`, `none`, `no`, `disabled`) /// refuses them and stops advertising them. /// `DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY`: a whole declared GPT-OSS call - /// written as the answer or inside the analysis is returned as a call by - /// default (`GPTOSSToolCallRecovery`); `0`, `off`, `false` or `no` returns - /// it as generated. + /// written as the answer or inside the analysis is returned as a call when + /// set to `1`, `on`, `true` or `yes` (`GPTOSSToolCallRecovery`); off by default. /// `DARKBLOOM_HARMONY_AUTO_TOOL_GRAMMAR`: GPT-OSS `auto` calls follow a /// declared name and that function's schema in the sampler by default; an /// off word restores calls as generated. diff --git a/provider-swift/Tests/ProviderCoreTests/Inference/Tools/GPTOSSToolCallRecoveryTests.swift b/provider-swift/Tests/ProviderCoreTests/Inference/Tools/GPTOSSToolCallRecoveryTests.swift index 54fd221a89..5feb31f368 100644 --- a/provider-swift/Tests/ProviderCoreTests/Inference/Tools/GPTOSSToolCallRecoveryTests.swift +++ b/provider-swift/Tests/ProviderCoreTests/Inference/Tools/GPTOSSToolCallRecoveryTests.swift @@ -149,16 +149,16 @@ struct GPTOSSToolCallRecoveryTests { #expect(GPTOSSToolCallRecovery.environmentKey == "DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY") } - @Test("`DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY` off turns it off; it reaches the launchd daemon") + @Test("`DARKBLOOM_GPTOSS_TOOL_CALL_RECOVERY` is off unless set on; it reaches the launchd daemon") func theSwitchReachesTheDaemon() { let key = GPTOSSToolCallRecovery.environmentKey - for value in ["0", "off", "false", "no", " OFF "] { + for value in ["", "0", "off", "false", "no", "2"] { #expect(!GPTOSSToolCallRecovery.isEnabled(environment: [key: value]), "\(value)") } - for value in ["", "1", "on", "true"] { + for value in ["1", "on", "true", "yes", " ON "] { #expect(GPTOSSToolCallRecovery.isEnabled(environment: [key: value]), "\(value)") } - #expect(GPTOSSToolCallRecovery.isEnabled(environment: [:])) + #expect(!GPTOSSToolCallRecovery.isEnabled(environment: [:])) #expect(LaunchAgent.inferencePassthroughEnvKeys.contains(key)) #expect(LaunchAgent.passthroughEnvironment(from: [key: "0"])[key] == "0") }