Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions changelog.d/gptoss-tool-call-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_LOCAL_ALLOW_TOOL_SCHEMA_METADATA` | exactly `1` enables (trimmed) | off | `provider-swift/Sources/ProviderCore/Inference/Tools/LocalToolSchemaMetadata.swift` (`current`) | Testing switch: the local API (`darkbloom start --local`) accepts tool schemas carrying the ingress repair's render marker (`x-darkbloom-original-boolean-schema`), as the coordinator forwards them, instead of refusing them. Logs a warning when on. The coordinator path is unchanged. Read once per process. |
| `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. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions provider-swift/Sources/ProviderCore/Service/LaunchAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,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")
}
Expand Down
Loading