ms-agent
ms-agent copied to clipboard
feat: improve Exa search integration with tracking header and updated API
Summary
- Add
x-exa-integrationtracking header for API usage attribution (ms-agent) - Remove deprecated
keywordsearch type; add current types:fast,deep-lite,deep,deep-reasoning,instant - Add content retrieval options:
highlightsandsummaryalongside existingtext - Add filtering support:
include_domains,exclude_domains,category,user_location - Fix
to_list()result formatting to include text/highlights/summary content fields with graceful fallback when fields are absent - Add unit tests covering schema, search engine initialization, tool definition validation, and response parsing
Note on
keywordsearch type: Thekeywordsearch type has been removed from the Exa API. This PR updates the integration to reflect the current API; agents passingtype="keyword"should usetype="fast"instead.
Usage Example
from ms_agent.tools.search.exa import ExaSearch
engine = ExaSearch() # uses EXA_API_KEY env var
request = ExaSearch.build_request_from_args(
query='latest advances in multi-agent systems',
type='neural',
num_results=5,
highlights=True,
summary=True,
category='research paper',
include_domains=['arxiv.org'],
start_published_date='2024-01-01',
)
result = engine.search(request)
for item in result.to_list():
print(item['title'], item.get('summary', ''))
Files Changed
ms_agent/tools/search/exa/search.py-- integration header, updated tool definition and request builderms_agent/tools/search/exa/schema.py-- new fields (highlights, summary, domain filters, category, user_location), improvedto_list()with content fallbacktests/search/test_exa_search.py-- new test file with comprehensive coverage
Test Plan
- [x]
ExaSearchRequestdefault values andto_dict()serialization - [x]
ExaSearchRequestwith domain/category/location filters - [x]
ExaSearchResult.to_list()with text-only, highlights-only, summary-only, and all-content responses - [x]
ExaSearchResult.to_list()graceful fallback when content fields are absent - [x]
ExaSearchResult.to_list()with empty response - [x]
ExaSearchsetsx-exa-integration: ms-agentheader on initialization - [x]
ExaSearchraisesAssertionErrorwhenEXA_API_KEYis not set - [x]
ExaSearch.get_tool_definition()does not includekeywordtype - [x]
ExaSearch.get_tool_definition()exposes all filter parameters - [x]
ExaSearch.build_request_from_args()correctly maps all parameters - [x] Realistic API response fixture parsing