Skip to content

fix: research node uses actual repo tools instead of hallucinating answers" #49

@simonabler

Description

@simonabler

Goal

The research_node currently sends the user'"'"'s question to the planner model with zero file access or code context. It reliably produces hallucinated answers for questions like "what does auth_middleware do?" or "where is X used?". Fix it to use the code intelligence, search, and file-reading tools that already exist and are wired into the coding workflow.

Current behavior

def research_node(state: GraphState) -> dict:
    prompt = "Answer the user'"'"'s request in analysis mode only.\n\n" + state.user_request
    answer = _invoke_agent("planner", [HumanMessage(content=prompt)])
    # ^ No tools. No repo context. Planner just guesses.

Target behavior

Research queries get the same context and tools as a coder, minus any write/git tools.

What changes

research_node rewrite

  1. Ensure context is loaded (context_loader_node result available in state)
  2. Build prompt including:
    • _format_intelligence_summary_for_prompt(state) (call graph, smells, dep graph — already implemented)
    • _format_context_summary(state.repo_facts) (tech stack, structure)
  3. Invoke agent with read-only tools: read_file, list_directory, search_in_repo
  4. Stream response to UI as normal

Read-only tool set

RESEARCH_TOOLS = [read_file, list_directory, search_in_repo]
# Explicitly excludes: write_file, git_command, run_shell, run_terminal

Code intelligence trigger

If state.call_graph is empty (intelligence not yet run), trigger code_intelligence_node first, then research. This ensures call graph is available for structural questions.

Example queries that must work correctly after this fix

  • "What does planner_plan_node do?" → reads the function, explains it
  • "Where is GraphState used?" → searches repo, lists files
  • "What are the main entry points of this codebase?" → uses context listing + call graph
  • "Find all places where we call the OpenAI API" → searches for API calls

Acceptance criteria

  • research_node uses read_file, list_directory, search_in_repo tools
  • Code intelligence summary injected into research prompt
  • If call graph is empty, code_intelligence_node runs first
  • Response streams to Web UI in real-time (same as coder)
  • No hallucinated file paths or function names in answers
  • Tests: research with mocked tools, verify tool calls are made

Dependencies

None — all required tools and intelligence already exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions