mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix: preserve falsy tool argument values
This commit is contained in:
@@ -16,7 +16,7 @@ function stripEmptyOptionalToolArgs(value) {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
const cleaned = stripEmptyOptionalToolArgs(parsed);
|
||||
return JSON.stringify(cleaned || {});
|
||||
return JSON.stringify(cleaned ?? {});
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -242,6 +242,26 @@ test("Responses -> OpenAI: empty-name tool call is deferred until output_item.do
|
||||
);
|
||||
});
|
||||
|
||||
test("Responses -> OpenAI: preserves falsy JSON-string tool arguments while cleaning", () => {
|
||||
const state = {};
|
||||
openaiResponsesToOpenAIResponse(
|
||||
{
|
||||
type: "response.output_item.added",
|
||||
item: { type: "function_call", call_id: "call_flag", name: "set_flag" },
|
||||
},
|
||||
state
|
||||
);
|
||||
const done = openaiResponsesToOpenAIResponse(
|
||||
{
|
||||
type: "response.output_item.done",
|
||||
item: { type: "function_call", call_id: "call_flag", name: "set_flag", arguments: "false" },
|
||||
},
|
||||
state
|
||||
);
|
||||
|
||||
assert.equal(done.choices[0].delta.tool_calls[0].function.arguments, "false");
|
||||
});
|
||||
|
||||
test("Responses -> OpenAI: strips empty optional args from JSON-string output_item.done arguments", () => {
|
||||
const state = {};
|
||||
openaiResponsesToOpenAIResponse(
|
||||
|
||||
Reference in New Issue
Block a user