feat: add Exa AI-powered search tool#1
Open
tgonzalezc5 wants to merge 1 commit into
Open
Conversation
The Exa search provider was sending a request without a `contents` block,
so each result came back without `text`/`highlights`/`summary`. Snippets
read `r.get("text", "")`, which was always empty in practice — the
fallback chain returned `[{url, title, snippet: ""}]` to the agent.
Changes:
- Request `contents.highlights` (3 sentences) and `contents.text`
(1000 chars) so snippets are populated.
- Drop the legacy `useAutoprompt` field; `type: "auto"` already covers it.
- Add `x-exa-integration: forgegod` header for usage attribution.
- Cascade snippet extraction across highlights → summary → text via a
small `_exa_snippet()` helper.
Adds tests covering: empty key short-circuit, request shape (header +
contents), HTTP error path, and the snippet fallback ladder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Exa search provider in
forgegod/tools/web.pywas sending a/searchrequest without acontentsblock, so the response had notext/highlights/summaryfields andr.get(\"text\", \"\")was always empty. In practice the Exa fallback was returning[{url, title, snippet: \"\"}]— useless to the researcher.This PR aligns the implementation with the current Exa API and adds attribution.
contents.highlights(3 sentences) andcontents.text(1000 chars) so snippets are actually populated.useAutopromptfield;type: \"auto\"already covers it.x-exa-integration: forgegodheader for usage attribution.highlights → summary → textvia a small_exa_snippet()helper.Usage
No config or API surface change. Existing
ReconConfig.exa_api_keyand theweb_search(provider=\"exa\", ...)entrypoint behave the same — they just return non-empty snippets now.Files changed
forgegod/tools/web.py— fix_search_exarequest body, add integration header, add_exa_snippet()helper.tests/test_tools.py— add 7 unit tests covering the request shape, header, snippet fallback, and error paths.Test plan
pytest tests/test_tools.py— 22 passed (7 new + 15 existing)ruff check forgegod/ tests/— clean[]contents.highlights+contents.textand headers includex-exa-integration: forgegod[](no exception bubbled to caller)