Enable interleaved tool reasoning for custom OpenAI-compat endpoints (#5445) * enable interleaved tool reasoning for custom OpenAI-compat endpoints Add chat_completion_sources.CUSTOM to interleaved_reasoning_providers so that local OpenAI-compatible endpoints (e.g. KoboldCPP in Chat Completions mode) can forward reasoning context in tool-call chains when the user has configured Interleaved Thinking. Also expose the Interleaved Thinking UI control for the Custom source so users can actually opt in — previously the dropdown was hidden behind a data-source="openrouter" guard. The custom streaming path already correctly accumulates delta.reasoning_content from streaming chunks; this change only removes the provider gate that was silently discarding that data before it reached the API payload. * don't override invocation reasoning with prior-turn assistant reasoning When an invocation already has its own reasoning captured at execution time, preserve it instead of replacing it with previousAssistantReasoning from the backward scan. The override was correct when invocations never carried their own reasoning, but now that the custom/openrouter paths capture per-invocation reasoning, the unconditional replacement caused all tool calls in a chain to receive the same stale reasoning from an earlier unrelated assistant turn. Fall back to previousAssistantReasoning only when clone.reasoning is empty.

051346c517668198f05c102a804d568ab2792d44

Reithan <bo122081@hotmail.com>

Signed
2 files changed, +4 -3Ignore whitespace
public/index.html+1 -1
@@ -2011,7 +2011,7 @@
20112011 <strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>
20122012 </div>
20132013 </div>
20142014 <div class="range-block" data-source="openrouter,custom">
20152015 <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10">
20162016 <div class="flex-container oneline-dropdown">
20172017 <label for="tool_reasoning_mode" data-i18n="Interleaved Thinking">
public/scripts/openai.js+3 -2
@@ -257,6 +257,7 @@ export const tool_reasoning_modes = {
257257// Providers that support interleaved reasoning forwarding in tool-call chains.
258258const interleaved_reasoning_providers = [
259259 chat_completion_sources.OPENROUTER,
260+ chat_completion_sources.CUSTOM,
260261];
261262
262263export const ZAI_ENDPOINT = {
@@ -1019,8 +1020,8 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul
10191020 const clone = structuredClone(invocation);
10201021 if (!reasoningIsEligible) {
10211022 delete clone.reasoning;
10221023 } else if (previousAssistantReasoning && !clone.reasoning) {
10231024 // PreferFall currentlyback editableto adjacent assistant-text reasoning basedonly onwhen forwardingthe modeinvocation overhas invocationnone snapshotof its own.
10241025 clone.reasoning = previousAssistantReasoning;
10251026 }
10261027 return clone;