fix(combo/fusion): flatten tool history in panel calls to prevent 503

Panel models in the fusion strategy must answer in prose. When the request
carried tools or prior tool_calls/tool messages, agentic panel models kept
emitting tool_calls instead of prose, so extractPanelText() returned empty
and the engine fell into the 503 "All fusion panel models failed" branch.

Panel fan-out now strips tools/tool_choice and flattens tool turns into
assistant prose (instead of dropping them), so panels keep the context but
cannot loop on tools. The judge still receives the unmodified history.

Co-authored-by: warelik <warelik@WARELIK-MB.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WARELIK
2026-06-18 09:55:08 +07:00
committed by decolua
co-authored by Cursor
parent 5e5e78d3e8
commit 9ab14e7714
3 changed files with 95 additions and 6 deletions
+16 -2
View File
@@ -102,7 +102,14 @@ export async function handleChat(request, clientRawRequest = null) {
return handleFusionChat({
body,
models: comboModels,
handleSingleModel: (b, m) => handleSingleModelChat(b, m, clientRawRequest, request, apiKey),
handleSingleModel: (b, m, isPanel) => {
let cleanRawReq = clientRawRequest;
if (isPanel && clientRawRequest) {
const { tools, tool_choice, ...cleanBody } = clientRawRequest.body || {};
cleanRawReq = { ...clientRawRequest, body: cleanBody };
}
return handleSingleModelChat(b, m, cleanRawReq, request, apiKey);
},
log,
comboName: modelStr,
judgeModel: comboStrategies[modelStr]?.judgeModel,
@@ -148,7 +155,14 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
return handleFusionChat({
body,
models: comboModels,
handleSingleModel: (b, m) => handleSingleModelChat(b, m, clientRawRequest, request, apiKey),
handleSingleModel: (b, m, isPanel) => {
let cleanRawReq = clientRawRequest;
if (isPanel && clientRawRequest) {
const { tools, tool_choice, ...cleanBody } = clientRawRequest.body || {};
cleanRawReq = { ...clientRawRequest, body: cleanBody };
}
return handleSingleModelChat(b, m, cleanRawReq, request, apiKey);
},
log,
comboName: modelStr,
judgeModel: comboStrategies[modelStr]?.judgeModel,