Skip to content

feat: add Exa AI-powered search tool#310

Open
tgonzalezc5 wants to merge 1 commit into
google:mainfrom
tgonzalezc5:feat/exa-search-tool
Open

feat: add Exa AI-powered search tool#310
tgonzalezc5 wants to merge 1 commit into
google:mainfrom
tgonzalezc5:feat/exa-search-tool

Conversation

@tgonzalezc5
Copy link
Copy Markdown

Summary

  • Adds ExaSearchTool, a client-side BaseTool that searches the open web via the Exa AI search API. It complements the existing GoogleSearchTool and VertexAiSearchTool, which are server-side Gemini built-ins, by giving agents a model-agnostic search option that returns structured results the model can read directly.
  • Exposes the practical Exa surface: search type (auto / fast / neural / hybrid / instant), numResults, category, domain and text include/exclude filters, published-date ranges, and per-result contents (highlights, text, summary) with snippet fallback.
  • Authentication uses the EXA_API_KEY environment variable or an explicit apiKey on the constructor; the SDK client is created lazily so the tool can be instantiated without a key.

Usage

import {LlmAgent, ExaSearchTool} from '@google/adk';

const agent = new LlmAgent({
  name: 'researcher',
  model: 'gemini-2.5-flash',
  instruction: 'Use exa_search to find recent web sources before answering.',
  tools: [new ExaSearchTool()],
});

The model can also pass per-call options to refine the query, e.g. category: 'research paper', includeDomains: ['arxiv.org'], or a date range.

Files changed

  • core/src/tools/exa_search_tool.ts — new tool, schema declaration, and response normalization with highlights → summary → text snippet fallback.
  • core/src/common.ts — exports ExaSearchTool and its public types.
  • core/test/tools/exa_search_tool_test.ts — vitest unit tests covering the function declaration schema, missing-key error, default + per-call argument forwarding, numResults clamping, snippet fallback, query validation, and env-var fallback.
  • core/package.json / package-lock.json — add exa-js dependency.

Test plan

  • npx vitest run --project unit:core core/test/tools/exa_search_tool_test.ts (8 / 8 passing)
  • npx vitest run --project unit:core core/test/tools/ — all 22 tool test files (150 tests) pass, no regressions
  • npx eslint core/src/tools/exa_search_tool.ts core/test/tools/exa_search_tool_test.ts — clean
  • npx prettier --check on the new files — clean
  • npm run build — succeeds

Adds an `ExaSearchTool` that lets agents query the open web through the
Exa AI search API. The tool follows the same `BaseTool` pattern as
`LoadMemoryTool`: a `_getDeclaration` describing the call schema and a
client-side `runAsync` that hits the API and returns structured results.

Authentication uses the `EXA_API_KEY` environment variable or an
`apiKey` constructor option. The tool exposes search type, category,
domain/text filtering, date ranges, and configurable per-result content
(highlights/text/summary) with graceful snippet fallback.
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 29, 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant