fix assistant exports and tool calls

This commit is contained in:
ajnart committed 2026-08-10 14:09:44 +02:00
1 parent f7eed7ce8a
commit 305c9af2da
15 files changed
+756 -29

No files matched your search

@@ -4,6 +4,7 @@ import {
getOpenRouterWebSearchRequests,
getOpenRouterWebSearchSources,
normalizeOpenRouterWebSearchSources,
withOpenRouterToolRequestOptions,
withOpenRouterWebSearch,
} from "./assistant-openrouter";
@@ -28,6 +29,21 @@ describe("withOpenRouterWebSearch", () => {
expect(withOpenRouterWebSearch(body)).toBe(body);
});
test("runs OpenRouter function tools sequentially while preserving optional server web search", () => {
expect(
withOpenRouterToolRequestOptions(
{
model: "deepseek/deepseek-v4-flash-latest",
tools: [{ type: "function", function: { name: "icon_findIcons", parameters: {} } }],
},
{ webSearchEnabled: true },
),
).toMatchObject({
parallel_tool_calls: false,
tools: [{ type: "function", function: { name: "icon_findIcons" } }, { type: "openrouter:web_search" }],
});
});
test("reads OpenRouter server-tool usage from a response", () => {
expect(getOpenRouterWebSearchRequests({ usage: { server_tool_use: { web_search_requests: 2 } } })).toBe(2);
expect(getOpenRouterWebSearchRequests({ usage: {} })).toBeUndefined();