feat: add Perplexity Search built-in tool#35709
Conversation
Adds a new built-in tool provider `perplexity` with a single tool `perplexity_search` that calls the Perplexity Search API (POST https://api.perplexity.ai/search) and returns ranked web results (title, url, snippet, date) as a JSON message, link messages, and a human-readable text message. The provider mirrors the existing Tavily reference pattern: - `perplexity.yaml` with a `perplexity_api_key` secret-input credential - `perplexity.py` provider whose credential validation runs a tiny search query through the tool - `tools/perplexity_search.{yaml,py}` exposing `query`, `max_results`, `search_domain_filter`, `search_recency_filter`, `search_after_date_filter`, and `search_before_date_filter` - minimal SVG icon under `_assets/` Registered in `builtin_tool/_position.yaml` so the provider shows up in the same UI ordering as the other built-ins. Tests: nine unit tests in `api/tests/unit_tests/core/tools/test_perplexity_search.py` covering payload construction, default/override behavior, domain filter parsing, result rendering, missing-query and missing-credentials paths, HTTP error mapping to ToolInvokeError, and end-to-end message generation with the HTTP layer mocked. Docs: - https://docs.perplexity.ai/docs/search/quickstart - https://docs.perplexity.ai/api-reference/search-post
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-30 06:30:36.218607724 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-30 06:30:26.458514946 +0000
@@ -1845,7 +1845,7 @@
ERROR Missing argument `app_model` in function `handler` [missing-argument]
--> tests/unit_tests/controllers/console/app/test_wraps.py:43:16
ERROR Cannot set item in `OrderedDict[str, bool | list[str] | str]` [unsupported-operation]
- --> tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py:137:47
+ --> tests/unit_tests/controllers/console/app/workflow_draft_variables_test.py:134:47
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/controllers/console/auth/test_login_logout.py:516:16
ERROR `None` is not subscriptable [unsupported-operation]
@@ -5045,6 +5045,9 @@
ERROR Object of class `BlobChunkMessage` has no attribute `text`
ERROR Object of class `BlobChunkMessage` has no attribute `text`
ERROR Object of class `BlobChunkMessage` has no attribute `text`
+ERROR Object of class `BlobChunkMessage` has no attribute `text`
+ERROR Object of class `BlobChunkMessage` has no attribute `text`
+ERROR Object of class `BlobChunkMessage` has no attribute `text`
ERROR Object of class `BlobChunkMessage` has no attribute `text`
ERROR Object of class `BlobChunkMessage` has no attribute `text`
ERROR Argument `SimpleNamespace` is not assignable to parameter `agent_message` with type `Message` in function `core.tools.tool_engine.ToolEngine._create_message_files` [bad-argument-type]
|
|
Hi, Severity: action required | Category: reliability How to fix: Use ssrf_proxy/httpx for calls Agent prompt to fix - you can give this to your LLM of choice:
We noticed a couple of other issues in this PR as well - happy to share if helpful. Spotted by Qodo code review - free for open-source projects. |
|
Thanks for the review. Pushed
Could a maintainer take another look when you have a moment? Happy to iterate further. 🙏 |
|
Re-checked all review comments at head
All 9 unit tests pass locally ( |
Summary
Adds a new built-in tool provider
perplexitywith a single toolperplexity_searchthat wraps Perplexity's Search API. It returns ranked web results (title, URL, snippet, date) as a JSON message, link messages, and a human-readable Markdown text message — mirroring the structure used by the existing Tavily provider that previously lived atapi/core/tools/provider/builtin/tavily/.Files added
api/core/tools/builtin_tool/providers/perplexity/perplexity.yaml– provider manifest with aperplexity_api_keysecret-inputcredential.api/core/tools/builtin_tool/providers/perplexity/perplexity.py– provider class. Credential validation runs a tinyquery=ping,max_results=1search through the tool and surfaces any error asToolProviderCredentialValidationError.api/core/tools/builtin_tool/providers/perplexity/tools/perplexity_search.{yaml,py}– tool manifest and implementation callingPOST https://api.perplexity.ai/searchwithAuthorization: Bearer <key>.api/core/tools/builtin_tool/providers/perplexity/_assets/icon.svg– minimal placeholder icon.api/core/tools/builtin_tool/_position.yaml– registersperplexityso it sorts alongside the other built-ins.Tool parameters
queryllm)max_resultssearch_domain_filter-domain.comentries for deny. Don't mix.search_recency_filterhour/day/week/month/year.search_after_date_filterm/d/yyyy(e.g.1/1/2025).search_before_date_filterm/d/yyyy(e.g.12/31/2025).The user-facing description is: "Search the web for up-to-date information using the Perplexity Search API. Returns ranked results with snippets, titles, URLs, and dates."
Docs
Testing
Nine unit tests in
api/tests/unit_tests/core/tools/test_perplexity_search.pymockrequests.postand cover:max_resultsand override behavior in_build_payload.resultsreturns a single friendly text message.ToolInvokeError.Run:
Result:
9 passed.uv run ruff checkanduv run ruff format --checkare also clean for the new files.