Introduce Research Agent and Web Search Integration#146
Conversation
- initialize input_token_estimate to 0 to prevent unbound variable errors - move len() call to assignment to store the actual token count - add call to add_use() so usage is persisted even when the final chunk lacks usage data
Introduces ResearchAgent to handle iterative web searches and scraping using LLM decisions, integrates /research command for standalone queries, adds per-thread web search enablement via /thread websearch on|off, and routes chat inputs to the agent when toggled on. Includes UI switch, prompt template, and metadata persistence enhancements.
Introduce a settings button to toggle a dedicated container for project context and web search options, improving UI organization in the chat view widget.
Overall ImpressionThis pull request introduces a research agent capability to the jrdev tool, enabling web-based information gathering through natural language queries integrated with the existing chat and command systems. The implementation extends the agentic pipeline with tool-based decisioning and UI toggles, providing a structured way to handle iterative research tasks while maintaining compatibility with thread metadata and streaming responses, which broadens the tool's scope for knowledge-intensive workflows without disrupting core functionality. Suggestions for Improvement
|
Add specific exception handling for HTTP status errors, network issues, timeouts, and invalid arguments in tool calls, with improved error messages and logging.
- Switch to `app.state.model` for research tasks instead of fixed `intermediate_reasoning` model
- Define `ALLOWED_TOOLS` as `{"web_search", "web_scrape_url"}` and validate tool names before execution
- Log and abort on unauthorized tool attempts with error messaging
…ch handler - Introduce sub-task IDs for UI updates during research iterations - Cache tool call results to skip duplicates and reduce redundancy - Stream tool feedback to chat threads when available, fallback to terminal prints
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