mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-22 04:19:40 +00:00
fix(responses): keep a placeholder message when dropped tool items leave none
An input of only a blank-id custom_tool_call and its blank-id output now drops both, which left messages:[] and an upstream 400. Apply the empty-input placeholder after conversion too, when no message survived.
This commit is contained in:
@@ -939,6 +939,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 &&
|
||||
|
||||
@@ -94,3 +94,11 @@ test("Responses -> Chat: a custom_tool_call with a call_id is untouched", () =>
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test("Responses -> Chat: when the blank-id pair is the whole input, one placeholder message stays", () => {
|
||||
const messages = toChat([
|
||||
{ type: "custom_tool_call", call_id: "", name: "apply_patch", input: "x" },
|
||||
{ type: "custom_tool_call_output", call_id: "", output: "patched text" },
|
||||
]);
|
||||
assert.deepEqual(messages, [{ role: "user", content: "..." }]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user