feat: support freshness parameter for Perplexity web_search provider (#15343)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 01aba2bfba
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Reviewed-by: @sebslight
This commit is contained in:
青雲
2026-02-14 11:18:16 +08:00
committed by GitHub
parent 7f227fc8cc
commit 89fa93ed75
6 changed files with 69 additions and 18 deletions

View File

@@ -159,7 +159,7 @@ describe("web_search perplexity baseUrl defaults", () => {
expect(body.model).toBe("sonar-pro");
});
it("rejects freshness for Perplexity provider", async () => {
it("passes freshness to Perplexity provider as search_recency_filter", async () => {
vi.stubEnv("PERPLEXITY_API_KEY", "pplx-test");
const mockFetch = vi.fn(() =>
Promise.resolve({
@@ -174,10 +174,11 @@ describe("web_search perplexity baseUrl defaults", () => {
config: { tools: { web: { search: { provider: "perplexity" } } } },
sandboxed: true,
});
const result = await tool?.execute?.(1, { query: "test", freshness: "pw" });
await tool?.execute?.(1, { query: "perplexity-freshness-test", freshness: "pw" });
expect(mockFetch).not.toHaveBeenCalled();
expect(result?.details).toMatchObject({ error: "unsupported_freshness" });
expect(mockFetch).toHaveBeenCalledOnce();
const body = JSON.parse(mockFetch.mock.calls[0][1].body as string);
expect(body.search_recency_filter).toBe("week");
});
it("defaults to OpenRouter when OPENROUTER_API_KEY is set", async () => {