feat: async research tool - runs in background, returns immediately

The research tool now spawns the scout agent in a background tokio task
and returns immediately with a research_id placeholder. This allows the
agent to continue working while research runs (30-120 seconds).

Key changes:
- New PendingResearchManager for tracking async research tasks
- research tool returns immediately with placeholder containing research_id
- research_status tool to check progress of pending research
- Auto-injection of completed research at natural break points:
  - Start of each tool iteration (before LLM call)
  - Before prompting user in interactive mode
- /research CLI command to list all research tasks
- Updated system prompt to explain async behavior

The agent can:
- Continue with other work while research runs
- Check status with research_status tool
- Yield turn to user if results are critical before continuing
This commit is contained in:
Dhanji R. Prasanna
2026-01-30 13:00:02 +11:00
parent 2e21502357
commit 5ab1598e03
11 changed files with 797 additions and 81 deletions

View File

@@ -91,7 +91,7 @@ If you create temporary files for verification or investigation, place these in
const SHARED_WEB_RESEARCH: &str = "\
# Web Research
When you need to look up documentation, search for resources, find data online, or research a topic to complete your task, use the `research` tool.
When you need to look up documentation, search for resources, find data online, or research a topic to complete your task, use the `research` tool. **Research is asynchronous** - it runs in the background while you continue working.
**Use the `research` tool** for any web research tasks:
- Researching APIs, SDKs, libraries, frameworks, or tools
@@ -99,7 +99,12 @@ When you need to look up documentation, search for resources, find data online,
- Investigating bugs, issues, or error messages
- Looking up documentation or specifications
Simply call `research` with a specific query describing what you need to know. The tool returns a structured research brief with options, trade-offs, and recommendations.
**How async research works:**
1. Call `research` with your query - it returns immediately with a `research_id`
2. Continue with other work while research runs in the background (30-120 seconds)
3. Results are automatically injected into the conversation when ready
4. Use `research_status` to check progress if needed
5. If you need results before continuing, say so and yield the turn to the user
IMPORTANT: If the user asks you to just respond with text (like \"just say hello\" or \"tell me about X\"), do NOT use tools. Simply respond with the requested text directly. Only use tools when you need to execute commands or complete tasks that require action.