fix: prevent provider_error 400 on dmodel/ultimate by using content placeholder
When assistant messages contain only tool_calls (no text/thinking), transform.ts was setting content to null. Qoder's gateway drops these null-content assistant messages, orphaning the following tool_result and causing upstream rejections: - dmodel (OpenAI): 'tool must follow a message with tool_calls' - ultimate (Anthropic): 'unexpected tool_use_id in tool_result blocks' Analysis of 28 historical sessions showed 100% failure rate on dmodel and 75% on ultimate for this pattern, while auto/GLM5.2 (GLM upstream) tolerated it. Fix: inject a single-space placeholder when tool_calls are present but content is empty, so the gateway preserves the assistant message and tool pairing stays valid. Also fixes pre-existing lint formatting in stream.ts and package.json. Adds regression test for the full assistant+toolResult pairing scenario.
This commit is contained in:
+6
-1
@@ -135,9 +135,14 @@ export function transformMessagesForQoder(messages: Message[]): QoderMessage[] {
|
||||
content = am.content || "";
|
||||
}
|
||||
|
||||
// Qoder's gateway drops assistant messages whose content is null, which
|
||||
// orphans the following tool_result and makes dmodel/ultimate upstreams
|
||||
// reject the request ("tool must follow a message with tool_calls").
|
||||
// When an assistant turn has tool calls but no text/thinking, inject a
|
||||
// single-space placeholder so the gateway keeps the message.
|
||||
const mapped: QoderMessage = {
|
||||
role: "assistant",
|
||||
content: content || null,
|
||||
content: content || (toolCalls.length > 0 ? " " : null),
|
||||
};
|
||||
if (toolCalls.length > 0) {
|
||||
mapped.tool_calls = toolCalls;
|
||||
|
||||
Reference in New Issue
Block a user