Introduce Research Agent and Web Search Integration #146
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.
Overview
This pull request introduces a new "Research Agent" capable of performing web searches and scraping web content to answer user queries. This agent can be invoked directly via a new
/researchcommand or integrated into existing chat threads through a new per-thread web search toggle. The changes enhance the application's ability to gather external information, providing more comprehensive responses to users.What This Means for Users
Users will now have two primary ways to leverage the new research capabilities:
/research <query>command: Users can directly initiate a research task from the command line by typing/researchfollowed by their query. The application will then use the Research Agent to find and summarize information related to the query.A Closer Look at the Changes
This pull request introduces several new components and modifies existing ones to support the research functionality:
ResearchAgent: A new agent (src/jrdev/agents/research_agent.py) has been added. This agent is designed to interpret user input, decide whether to perform a web search, scrape a URL, or summarize gathered information. It operates in an iterative loop, using a dedicated prompt (src/jrdev/prompts/researcher/research_prompt.md) to guide its decision-making process./researchCommand: A new command handler (src/jrdev/commands/handle_research.py) has been implemented. This handler orchestrates the interaction with theResearchAgent, managing the research thread, tool calls (web search and scrape), and presenting the final summary to the user.ChatViewWidget(src/jrdev/ui/tui/chat/chat_view_widget.py) has been updated to include a newweb_search_switchandweb_search_label._handle_websearch_togglefunction has been added tosrc/jrdev/commands/thread.pyto manage the state of the web search toggle for individual threads.MessageThreadclass (src/jrdev/messages/thread.py) now supports additional metadata fields, allowing theweb_search_enabledstate to be stored and retrieved with each thread.Applicationclass (src/jrdev/core/application.py) has been updated to route user messages through thehandle_researchfunction if web search is enabled for the current thread.create_threadmethod inApplicationnow accepts optionalmeta_datato support initializing threads with specific settings, such asweb_search_enabled.CommandHandler(src/jrdev/core/commands.py) has been updated to register the new/researchcommand.src/jrdev/services/streaming/openai_stream.pyto improve token estimation.GitOverviewWidget(src/jrdev/ui/tui/git/git_overview_widget.py) now clears the commit message textarea after a successful commit, improving the user experience.Generated by JrDev AI using google/gemini-2.5-flash