Skip to content

API Reference parrot.registry.routing.route_bank

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

parrot.registry.routing.route_bank

View source

routes.yaml phrase-bank loading and merging (FEAT-755).

Layout mirrors the FEAT-707 per-tenant skills tree::

<agent_root>/routes.yaml                      # agent-level bank
<agent_root>/tenants/<tenant>/routes.yaml     # per-tenant override

Merge order is defaults <- agent <- tenant. Nothing here raises for a bad file: a malformed bank is warned about and skipped.

Attribute ROUTES_FILENAME

Type: Final[str]

Class ResolvedRouteBanks

Merged global bank, per-tenant banks, and optional threshold overrides.

Fields:

Field Type Default Description
routes dict[str, list[str]]
tenant_routes dict[str, dict[str, list[str]]]
threshold Optional[float] None
margin Optional[float] None

Class RouteBankFile

Schema of one routes.yaml.

Fields:

Field Type Default Description
version int 1
routes dict[str, list[str]]
replace bool False
threshold Optional[float] None
margin Optional[float] None

Alias TENANTS_DIRNAME

Re-exported from parrot.skills.tenancy.TENANTS_DIRNAME.

Function agent_routes_path

Return agent_root/routes.yaml.

agent_routes_path(agent_root: Path) -> Path

Parameter Type Default Description
agent_root Path

Returns: Path

Function load_route_bank

Load and validate one routes.yaml.

load_route_bank(path: Path) -> Optional[RouteBankFile]

Parameter Type Default Description
path Path Route-bank file to load.

Returns: Optional[RouteBankFile] — The validated bank, or None when the file is missing or invalid.

Attribute logger

Function merge_route_banks

Merge base with each overlay from left to right.

merge_route_banks(base: Mapping[str, Sequence[str]], *overlays: RouteBankFile) -> dict[str, list[str]]

Parameter Type Default Description
base Mapping[str, Sequence[str]] Initial phrase bank.
*overlays RouteBankFile () Validated route-bank overlays.

Returns: dict[str, list[str]] — A new merged mapping. Input mappings and models are not mutated.

Function resolve_route_banks

Resolve defaults <- agent file <- per-tenant files.

resolve_route_banks(agent_root: Optional[Path], *, defaults: Mapping[str, Sequence[str]], tenant_based: bool) -> ResolvedRouteBanks

Parameter Type Default Description
agent_root Optional[Path] Agent definition root, or None when no file tree exists.
defaults Mapping[str, Sequence[str]] Built-in phrase bank.
tenant_based bool Whether to discover and merge tenant banks.

Returns: ResolvedRouteBanks — The resolved global and per-tenant phrase banks.

Alias secure_path

Re-exported from parrot.utils.paths.secure_path.

Function tenant_routes_path

Return the contained agent_root/tenants/<tenant>/routes.yaml.

tenant_routes_path(agent_root: Path, tenant: str) -> Path

Parameter Type Default Description
agent_root Path Root directory of the agent definition.
tenant str Untrusted tenant identifier.

Returns: Path — The contained path to the tenant route bank.

Raises:

  • ValueError — If the tenant id is invalid/reserved or the path escapes agent_root.

Alias validate_tenant_id

Re-exported from parrot.skills.tenancy.validate_tenant_id.

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