Skip to content

feat(tools): add Perplexity Search tool#5554

Open
jliounis wants to merge 2 commits intogoogle:mainfrom
jliounis:add-perplexity-search-tool
Open

feat(tools): add Perplexity Search tool#5554
jliounis wants to merge 2 commits intogoogle:mainfrom
jliounis:add-perplexity-search-tool

Conversation

@jliounis
Copy link
Copy Markdown

Summary

Adds PerplexitySearchTool — a new built-in tool that performs web search via the Perplexity Search API (POST https://api.perplexity.ai/search).

The tool follows the existing search-tool pattern in this repo (mirrors DiscoveryEngineSearchTool / VertexAiSearchTool): it subclasses FunctionTool, exposes a single query argument to the model, and lets developers pin server-side options (max_results, search_recency_filter, search_domain_filter, etc.) at construction time. HTTP calls go through httpx.AsyncClient, which is already in core deps — no new dependency is added.

Every outgoing request includes an X-Pplx-Integration: google-adk/<version> header for attribution. The API key can be supplied via constructor or the PERPLEXITY_API_KEY environment variable.

API reference: https://docs.perplexity.ai/api-reference/search-post

Files

  • src/google/adk/tools/perplexity_search_tool.py — tool implementation
  • src/google/adk/tools/__init__.py — lazy export entry
  • tests/unittests/tools/test_perplexity_search_tool.py — 12 unit tests
  • contributing/samples/perplexity_search_agent/ — example agent (mirrors google_search_agent sample)

Testing plan

  • Unit tests added under tests/unittests/tools/test_perplexity_search_tool.py (12 tests, all passing locally with pytest).
  • Tests use httpx.MockTransport so no live HTTP calls are made.
  • Tests assert the X-Pplx-Integration attribution header, Authorization: Bearer header, request URL, request method, and the request body shape (with and without options).
  • Tests cover error paths (HTTP status error, transport error) and the lazy import in google.adk.tools.
  • pyink and isort (Google profile) clean.
$ pytest tests/unittests/tools/test_perplexity_search_tool.py -v
============================== 12 passed in 1.46s ==============================

Add a new built-in tool, PerplexitySearchTool, that calls the Perplexity
Search API (POST https://api.perplexity.ai/search) via httpx.AsyncClient.
The tool wraps a single `query` argument for the model and lets developers
pin server-side options (max_results, recency, domain filter, etc.) at
construction time, mirroring the pattern of DiscoveryEngineSearchTool.

Every outgoing request includes the X-Pplx-Integration header set to
google-adk/<package-version> for attribution. The API key can be supplied
via constructor or PERPLEXITY_API_KEY.

- src/google/adk/tools/perplexity_search_tool.py: tool implementation
- src/google/adk/tools/__init__.py: lazy export
- tests/unittests/tools/test_perplexity_search_tool.py: 12 tests with a
  mocked httpx transport, including an assertion that the attribution
  header is sent
- contributing/samples/perplexity_search_agent: example agent

Docs: https://docs.perplexity.ai/api-reference/search-post
Signed-off-by: james-pplx <james-pplx@users.noreply.github.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 30, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Apr 30, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Apr 30, 2026

Response from ADK Triaging Agent

Hello @james-pplx, thank you for creating this PR!

To help us track and review this new feature, could you please create a GitHub issue and associate it with this PR?

Thanks!

@rohityan rohityan self-assigned this Apr 30, 2026
Position PerplexitySearchTool as the recommended general-purpose web
search tool when no GCP / Discovery Engine setup is available. Adds a
short tip in the README quickstart and expands the class docstring to
note when to prefer it over DiscoveryEngineSearchTool.
@jliounis
Copy link
Copy Markdown
Author

jliounis commented May 5, 2026

Hi @GeorgeWeale — once this lands, would you consider positioning PerplexitySearchTool as the recommended general-purpose web search tool in ADK's docs (and eventually as the default web-search example for new users)?

The reasoning is mostly about onboarding friction: DiscoveryEngineSearchTool is excellent for enterprise / private-corpus search, but it requires a GCP project, a Discovery Engine app, and an indexed data store before a developer sees any results. google_search works great as a Gemini-grounded option but ties the agent to that grounding pathway. PerplexitySearchTool complements both — it's a single env var (PERPLEXITY_API_KEY) and works against the public web with no infra.

Rationale (more general):

  • Single API + index — no separate retrieval/embedding step
  • Snippets are pre-filtered for RAG (high info density per token)
  • One env var (PERPLEXITY_API_KEY) for setup; no GCP project required
  • The Perplexity API team actively maintains this integration
  • We're committed to long-term parity with whichever default ADK ships today

I've pushed a tiny doc-only commit (1894da3) on this branch that adds a short tip in the README quickstart and a note in the class docstring positioning Perplexity as the no-config default; happy to revert that if you'd rather land it as a follow-up. Either way, thanks for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants