Skip to content

API Reference parrot_tools.research.router

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.research.router

View source

ResearchRouter — cross-category dispatch tool (FEAT-426 Module 4).

A standalone AbstractTool (not a toolkit method) that classifies a natural-language research question into one or both of the two research categories (open_data, academic) and dispatches concurrently to the relevant toolkit methods.

Two framework traps apply here and are both deliberately guarded against:

  1. AbstractTool does not infer an args schema from _execute — an explicit args_schema is mandatory, or every parameter the LLM supplies is silently discarded (abstract.py:629). See ResearchRouterArgs below.
  2. Tools have no back-reference to the calling agent's LLM (abstract.py:265, documented framework invariant). The classifier client is injected through the constructor instead — see the db.py-style llm= pattern.

See spec §2 "Error Contract" and §3 Module 4.

Alias AcademicResearchToolkit

Re-exported from parrot_tools.research.academic.AcademicResearchToolkit.

Alias OpenDataToolkit

Re-exported from parrot_tools.research.open_data.OpenDataToolkit.

Class ResearchRouter

Answer a research question by dispatching to the right toolkit(s).

Classifies the query into open_data and/or academic using an explicitly injected LLM client (constructor llm=), falling back to keyword heuristics when llm is None or classification fails. Dispatches concurrently to the selected toolkit(s) and merges the results into a single, always-successful ToolResult — per-category failures are recorded in the payload rather than raised (spec §2 Error Contract).

Parameter Type Default Description
open_data Optional[OpenDataToolkit] None OpenDataToolkit instance. Constructed if omitted.
academic Optional[AcademicResearchToolkit] None AcademicResearchToolkit instance. Constructed if omitted.
llm AbstractClient | str | None None The classifier client — an AbstractClient instance, a string model spec resolved via LLMFactory.create(), or None to use keyword heuristics only. Tools have no back-reference to the calling agent's LLM by design, so it must be injected here explicitly.
**kwargs {} Forwarded to AbstractTool.__init__.

Attributes:

Attribute Type Description
name str
description str
args_schema type[BaseModel]
auto_open bool

Class ResearchRouterArgs

Explicit args schema — REQUIRED, see module docstring trap #1.

Attributes:

Attribute Type Description
query str
categories list[str] | None
max_results int

Attribute VALID_CATEGORIES

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally