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.
This commit is contained in:
+1
-1
@@ -2011,7 +2011,7 @@
|
|||||||
<strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>
|
<strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block" data-source="openrouter">
|
<div class="range-block" data-source="openrouter,custom">
|
||||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10">
|
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10">
|
||||||
<div class="flex-container oneline-dropdown">
|
<div class="flex-container oneline-dropdown">
|
||||||
<label for="tool_reasoning_mode" data-i18n="Interleaved Thinking">
|
<label for="tool_reasoning_mode" data-i18n="Interleaved Thinking">
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ export const tool_reasoning_modes = {
|
|||||||
// Providers that support interleaved reasoning forwarding in tool-call chains.
|
// Providers that support interleaved reasoning forwarding in tool-call chains.
|
||||||
const interleaved_reasoning_providers = [
|
const interleaved_reasoning_providers = [
|
||||||
chat_completion_sources.OPENROUTER,
|
chat_completion_sources.OPENROUTER,
|
||||||
|
chat_completion_sources.CUSTOM,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ZAI_ENDPOINT = {
|
export const ZAI_ENDPOINT = {
|
||||||
@@ -1019,8 +1020,8 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul
|
|||||||
const clone = structuredClone(invocation);
|
const clone = structuredClone(invocation);
|
||||||
if (!reasoningIsEligible) {
|
if (!reasoningIsEligible) {
|
||||||
delete clone.reasoning;
|
delete clone.reasoning;
|
||||||
} else if (previousAssistantReasoning) {
|
} else if (previousAssistantReasoning && !clone.reasoning) {
|
||||||
// Prefer currently editable assistant-text reasoning based on forwarding mode over invocation snapshot.
|
// Fall back to adjacent assistant-text reasoning only when the invocation has none of its own.
|
||||||
clone.reasoning = previousAssistantReasoning;
|
clone.reasoning = previousAssistantReasoning;
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
|
|||||||
Reference in New Issue
Block a user