Skip to content

Copilot/add tavily source#255

Closed
panjunchang wants to merge 5 commits into
HKUDS:mainfrom
panjunchang:copilot/add-tavily-source
Closed

Copilot/add tavily source#255
panjunchang wants to merge 5 commits into
HKUDS:mainfrom
panjunchang:copilot/add-tavily-source

Conversation

@panjunchang

Copy link
Copy Markdown

Summary

Why

Changes

Test Plan

  • Existing tests pass (pytest --ignore=agent/tests/e2e_backtest --tb=short -q)
  • New tests added (if applicable)
  • Tested manually (describe below)

Checklist

  • No changes to protected areas (src/agent/, src/session/, src/providers/) without prior discussion
  • No hardcoded values (API keys, file paths, magic numbers)
  • Code follows CONTRIBUTING.md guidelines
  • Documentation updated (if user-facing change)
Copilot AI review requested due to automatic review settings June 18, 2026 01:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Tavily as a preferred web-search backend (when configured) with ddgs as a fallback, and exposes Tavily API key configuration via the Web UI + settings API.

Changes:

  • Implement Tavily-first search path in WebSearchTool, with fallback to ddgs on failure.
  • Add Tavily API key support to settings API/models and persist it to the agent .env.
  • Add UI + frontend API typings to configure/clear the Tavily key, plus unit tests for Tavily-preferred behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/pages/Settings.tsx Adds Tavily API key input + clear toggle and includes it in data-source settings updates.
frontend/src/lib/api.ts Extends data-source settings request/response typings for Tavily key configuration.
agent/tests/test_web_search_tool.py Adds tests asserting Tavily is preferred when configured and ddgs is used as fallback.
agent/src/tools/web_search_tool.py Implements Tavily availability detection + Tavily search path before ddgs fallback.
agent/requirements.txt Adds tavily-python dependency for Tavily client support.
agent/api_server.py Adds Tavily key fields to data-source settings endpoints and runtime env syncing.
agent/.env.example Documents TAVILY_API_KEY and how it affects web search behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +462 to +470
<input
type="password"
value={tavilyApiKey}
onChange={(event) => setTavilyApiKey(event.target.value)}
className={`${fieldClass} pl-9`}
placeholder={tavilyStatus}
autoComplete="off"
disabled={clearTavilyApiKey}
</div>
from contextlib import contextmanager
from types import ModuleType
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
@warren618

Copy link
Copy Markdown
Collaborator

Thanks for the PR, and for the thoughtful Tavily-preferred / ddgs-fallback design — it's a clear improvement over the earlier attempt.

We're closing this one for the same reason we closed #75: web_search already runs as a keyless multi-engine aggregator via ddgs (DuckDuckGo, Google, Bing, Brave, Mojeek, Yahoo), hardened in #231/#232 with an ordered backend list, retry/backoff, and the VIBE_TRADING_SEARCH_BACKENDS override. We want web search to keep working out of the box with no paid API key, so we'd prefer not to add tavily-python as a dependency or a Tavily key as a required-for-best-results setting.

This isn't a quality issue with your code — it's a standing decision about not taking on a paid search dependency. If you think there's a gap the current ddgs path doesn't cover (specific queries where it consistently fails), we'd genuinely welcome an issue with those cases so we can improve the free path. Thanks again for contributing.

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

Labels

None yet

4 participants