feat: re-add web search with robust dual-source routing (#283) - #284
Merged
Conversation
Re-introduces web search (Serper API) and page fetching (Jina Reader) to the ReAct agent with improvements over the reverted PR #232: - Dynamic prompt adapts tool list based on API key availability - Graceful fallback when web_search is called without SERPER_API_KEY - Error responses from Serper (401, etc.) handled without crashing - visit_page errors (404, network) caught and surfaced to the LLM - search_history entries include 'source' field (local/web) - CLI gains --serper-api-key and --jina-api-key flags - 13 comprehensive tests covering all routing and edge case scenarios Closes #283 Made-with: Cursor
Made-with: Cursor
Collaborator
Author
|
if passes, this is good |
Made-with: Cursor
Made-with: Cursor
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
Re-introduces web search (Serper API) and page fetching (Jina Reader) to the ReAct agent, replacing the reverted PR #232 with robust error handling and dual-source routing.
Key improvements over the original:
SERPER_API_KEYis configuredweb_searchis called without an API key (guides LLM to useleann_search)visit_pageerrors (404, network failures) caught and surfaced as observationssearch_historyentries now include asourcefield ("local"or"web") for debugging--serper-api-keyand--jina-api-keyflagsFiles changed:
packages/leann-core/src/leann/web_search.py— re-added with typo fixpackages/leann-core/src/leann/react_agent.py— dual-source routing, dynamic prompts, error handlingpackages/leann-core/src/leann/cli.py— new CLI args, source tags in search history displaytests/test_react_dual_source.py— 13 tests covering all scenarios from issue ReAct agent: verify dual-source routing (local vs web) end-to-end #283Test plan
leann_searchwhen no keyvisit_pagecontent truncated to 15k charssearch_historyentries includesourcefieldAll 13 tests pass locally (193s).
Closes #283