fix(web_search): Fix invalid model name sent to Perplexity (#12795)

* fix(web_search): Fix invalid model name sent to Perplexity

* chore: Only apply fix to direct Perplexity calls

* fix(web_search): normalize direct Perplexity model IDs

* fix: add changelog note for perplexity model normalization (#12795) (thanks @cdorsey)

* fix: align tests and fetch type for gate stability (#12795) (thanks @cdorsey)

* chore: keep #12795 scoped to web_search changes

---------

Co-authored-by: Sebastian <19554889+sebslight@users.noreply.github.com>
This commit is contained in:
Chase Dorsey
2026-02-09 13:43:57 -05:00
committed by GitHub
parent 40b11db80e
commit 512b2053c5
4 changed files with 66 additions and 2 deletions

View File

@@ -151,6 +151,12 @@ describe("web_search perplexity baseUrl defaults", () => {
expect(mockFetch).toHaveBeenCalled();
expect(mockFetch.mock.calls[0]?.[0]).toBe("https://api.perplexity.ai/chat/completions");
const request = mockFetch.mock.calls[0]?.[1] as RequestInit | undefined;
const requestBody = request?.body;
const body = JSON.parse(typeof requestBody === "string" ? requestBody : "{}") as {
model?: string;
};
expect(body.model).toBe("sonar-pro");
});
it("rejects freshness for Perplexity provider", async () => {
@@ -194,6 +200,12 @@ describe("web_search perplexity baseUrl defaults", () => {
expect(mockFetch).toHaveBeenCalled();
expect(mockFetch.mock.calls[0]?.[0]).toBe("https://openrouter.ai/api/v1/chat/completions");
const request = mockFetch.mock.calls[0]?.[1] as RequestInit | undefined;
const requestBody = request?.body;
const body = JSON.parse(typeof requestBody === "string" ? requestBody : "{}") as {
model?: string;
};
expect(body.model).toBe("perplexity/sonar-pro");
});
it("prefers PERPLEXITY_API_KEY when both env keys are set", async () => {