feat: add Tavily search tool and research-agent support #148
+548
−3
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
Adds a new
searchtool backed by the Tavily API for web search capabilities. This enables creating research-focused agents that can search the web and cite sources.Changes
New Files
code_puppy/tools/search_tool.py- Tavily API integration with:SearchResult,SearchOutput)search_depth,topic,time_range, domain allow/deny listsMissingApiKey,RateLimited,UpstreamErrortests/tools/test_search_tool.py- Unit tests covering:Modified Files
code_puppy/tools/__init__.py- Registersearchin tool registryREADME.md- Usage docs for Research AgentAGENTS.md- Addedsearchto available tools list.env.example- AddedSEARCH_API_KEYtemplateUsage
Example JSON Agent (
~/.code_puppy/agents/research-agent.json):{ "name": "research-agent", "display_name": "Research Agent", "description": "Diligent researcher that searches the web and summarizes with citations", "tools": ["search", "list_files", "read_file", "agent_share_your_reasoning"], "system_prompt": [ "You are an expert Technical Research Assistant.", "Objective: gather factual, publicly available information to answer user queries accurately.", "Protocol:", "1) Analyze the question and craft precise search queries.", "2) Use the search tool; do not guess URLs.", "3) Evaluate snippets; refine the query if evidence is weak.", "4) Use search parameters when needed: search_depth=advanced for deep research, topic=news + time_range for recency, include_domains/exclude_domains for source quality.", "5) Summarize findings clearly.", "6) Cite sources as [Title](URL) inline with claims." ] }Testing
uv run pytest tests/tools/test_search_tool.py -v # 9 passed ✅Checklist