tools.research_tool module

Async multi-step research tool: start, poll, and list background tasks.

Registers three tools (start_research_task, get_research_result, list_research_tasks) that drive a fire-and-forget research workflow. A started task spawns a detached asyncio background coroutine that runs a plan-execute-synthesize loop against the LLM via OpenRouterClient, streaming progress and the final report into a stargazer:research:<task_id> Redis hash (with a one-week TTL) so callers can poll for results across generation cycles. Live task handles and their owners are also tracked in the module-level _running_tasks and _running_owners dictionaries.

Access is gated by the WEB_SEARCH privilege, and default-key usage is rate-limited via tools.manage_api_keys so unprivileged or quota-exhausted callers cannot run unbounded research jobs on the shared key.