ms-agent icon indicating copy to clipboard operation
ms-agent copied to clipboard

feat: improve Exa search integration with tracking header and updated API

Open tgonzalezc5 opened this issue 7 months ago • 0 comments

Summary

  • Add x-exa-integration tracking header for API usage attribution (ms-agent)
  • Remove deprecated keyword search type; add current types: fast, deep-lite, deep, deep-reasoning, instant
  • Add content retrieval options: highlights and summary alongside existing text
  • 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 keyword search type: The keyword search type has been removed from the Exa API. This PR updates the integration to reflect the current API; agents passing type="keyword" should use type="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 builder
  • ms_agent/tools/search/exa/schema.py -- new fields (highlights, summary, domain filters, category, user_location), improved to_list() with content fallback
  • tests/search/test_exa_search.py -- new test file with comprehensive coverage

Test Plan

  • [x] ExaSearchRequest default values and to_dict() serialization
  • [x] ExaSearchRequest with 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] ExaSearch sets x-exa-integration: ms-agent header on initialization
  • [x] ExaSearch raises AssertionError when EXA_API_KEY is not set
  • [x] ExaSearch.get_tool_definition() does not include keyword type
  • [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

tgonzalezc5 avatar Apr 14 '26 16:04 tgonzalezc5