openclaw/src/agents/pi-tools.model-provider-collision.test.ts
Vincent Koc fbd88e2c8f
Main recovery: restore formatter and contract checks (#49570)
* Extensions: fix oxfmt drift on main

* Plugins: restore runtime barrel exports on main

* Config: restore web search compatibility types

* Telegram: align test harness with reply runtime

* Plugin SDK: fix channel config accessor generics

* CLI: remove redundant search provider casts

* Tests: restore main typecheck coverage

* Lobster: fix test import formatting

* Extensions: route bundled seams through plugin-sdk

* Tests: use extension env helper for xai

* Image generation: fix main oxfmt drift

* Config: restore latest main compatibility checks

* Plugin SDK: align guardrail tests with lint

* Telegram: type native command skill mock
2026-03-18 00:30:01 -07:00

49 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
HTML_ENTITY_TOOL_CALL_ARGUMENTS_ENCODING,
XAI_TOOL_SCHEMA_PROFILE,
} from "./model-compat.js";
import { __testing } from "./pi-tools.js";
import type { AnyAgentTool } from "./pi-tools.types.js";
const baseTools = [
{ name: "read" },
{ name: "web_search" },
{ name: "exec" },
] as unknown as AnyAgentTool[];
function toolNames(tools: AnyAgentTool[]): string[] {
return tools.map((tool) => tool.name);
}
describe("applyModelProviderToolPolicy", () => {
it("keeps web_search for non-xAI models", () => {
const filtered = __testing.applyModelProviderToolPolicy(baseTools);
expect(toolNames(filtered)).toEqual(["read", "web_search", "exec"]);
});
it("removes web_search for OpenRouter xAI model ids", () => {
const filtered = __testing.applyModelProviderToolPolicy(baseTools, {
modelCompat: {
toolSchemaProfile: XAI_TOOL_SCHEMA_PROFILE,
nativeWebSearchTool: true,
toolCallArgumentsEncoding: HTML_ENTITY_TOOL_CALL_ARGUMENTS_ENCODING,
},
});
expect(toolNames(filtered)).toEqual(["read", "exec"]);
});
it("removes web_search for direct xai-capable models too", () => {
const filtered = __testing.applyModelProviderToolPolicy(baseTools, {
modelCompat: {
toolSchemaProfile: XAI_TOOL_SCHEMA_PROFILE,
nativeWebSearchTool: true,
},
});
expect(toolNames(filtered)).toEqual(["read", "exec"]);
});
});