mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-22 04:19:40 +00:00
fix(responses): keep a placeholder message when skipped items leave none
An input of only a replayed image_generation_call is skipped item by item, which left messages:[] and an upstream 400. Apply the empty-input placeholder after conversion too, when no message survived.
This commit is contained in:
@@ -938,6 +938,12 @@ export function openaiResponsesToOpenAIRequest(
|
||||
];
|
||||
});
|
||||
|
||||
// Upstream providers reject messages:[] (see the empty-input placeholder above). Skipped
|
||||
// replay items or dropped tool results can still leave nothing: keep the same placeholder.
|
||||
if (Array.isArray(result.messages) && result.messages.length === 0) {
|
||||
result.messages = [{ role: "user", content: "..." }];
|
||||
}
|
||||
|
||||
// Translate tool_choice object format: Responses {type,name} → Chat {type,function:{name}}
|
||||
if (
|
||||
result.tool_choice &&
|
||||
|
||||
@@ -55,3 +55,10 @@ test("other unrepresentable input items are still rejected", () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("an input of only a replayed image_generation_call still sends one message", () => {
|
||||
const result = translate([
|
||||
{ type: "image_generation_call", id: "ig_3", status: "completed", result: "Zml4dHVyZQ==" },
|
||||
]) as { messages?: Array<{ role?: string; content?: unknown }> };
|
||||
assert.deepEqual(result.messages, [{ role: "user", content: "..." }]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user