feat: add Exa AI-powered search tool#19
Merged
Merged
Conversation
Slots Exa into the existing Tavily/Z.AI/Ollama/DuckDuckGo fallback chain in performWebSearchForTask, just before Tavily, so users with an Exa key get neural search with text+highlights content. - KeychainService: add get/setExaAPIKey - AgentViewModel: add exaAPIKey property bound to Keychain - WebSearch: new performExaSearchInternal (POST api.exa.ai/search, type: auto, contents: text + highlights) with a typed Decodable response and a snippet helper that cascades highlights → summary → text - Settings: Exa key field next to the existing Tavily field - README: tool table reflects the new provider list - Tests: ExaSearchTests covers parsing, snippet fallback, and the empty-key guard
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
api.exa.ai/search) as a web-search provider, fitting into the existing Tavily / Z.AI / Ollama / DuckDuckGo fallback chain inperformWebSearchForTask.KeychainService.get/setExaAPIKey) and exposed in Settings next to the existing Tavily field. When configured, Exa is preferred over Tavily; DuckDuckGo remains the keyless fallback.type: autoandcontents: { text, highlights }. A typedDecodableresponse model is decoded, and aexaSnippethelper cascades throughhighlights → summary → textso the formatter handles whatever combination Exa returns for a given page.Why Exa
Exa's
autosearch type chooses between neural and keyword retrieval per query, which complements the existing keyword-style providers and is useful for the more open-ended research queries the agent often makes. The new field is opt-in and does not change behavior for users who only have a Tavily key set.Usage
Open Settings → "Web Search" and paste an Exa key:
Once set, calls through
performWebSearchForTask(e.g. theweb_search/searchtool) hit Exa first.Files changed
Agent/AgentViewModel/TaskUtilities/WebSearch.swift— newperformExaSearchInternal, typed response decoder, snippet helper; Exa step inserted into the fallback chainAgent/Services/KeychainService.swift—get/setExaAPIKeyAgent/AgentViewModel/Core/AgentViewModel.swift—exaAPIKeyproperty bound to KeychainAgent/Views/Settings/SettingsView.swift— Exa API key field in the Web Search sectionAgent.xcodeproj/project.pbxproj— registerExaSearchTests.swiftin the AgentTests targetAgentTests/ExaSearchTests.swift— unit tests for response parsing and snippet fallbackREADME.md— tool table updated to mention Exa/Tavily/DuckDuckGoTest plan
swiftc -parsepasses on every modified Swift fileExaSearchTestscovers: standard response, empty results, malformed JSON, missing optional fields, snippet cascade (highlights → summary → text), whitespace-only highlight skipping, empty-key guardxcodebuild -scheme "Agent!" build(requires full Xcode; my local env only has Command Line Tools, so I couldn't run it — happy to iterate if CI flags anything)xcodebuild -scheme "Agent!" testruns the newExaSearchTestssuite (same caveat)web_searchand confirm Exa results renderNotes
URLSession+JSONDecoder, matching how the other providers are written.