Skip to content

API Reference parrot.registry.capabilities.registry

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

parrot.registry.capabilities.registry

View source

CapabilityRegistry — semantic resource index for intent routing.

Provides embedding-based similarity search over registered capability entries (datasets, tools, graph nodes, etc.) to identify the best routing strategy for a given user query.

Alias CapabilityEntry

Re-exported from parrot.registry.capabilities.models.CapabilityEntry.

Class CapabilityRegistry

Semantic resource index for intent routing.

Stores capability entries and provides embedding-based cosine similarity search to discover relevant strategies for a given user query.

Supports registration from:

  • Manual CapabilityEntry objects.
  • DataSource instances (DatasetManager sources).
  • AbstractTool instances.
  • YAML configuration files.
Parameter Type Default Description
not_for_penalty float 0.5 Score multiplier applied when a query matches a not_for pattern (default 0.5 — halves the score).

Method CapabilityRegistry.register

Register a capability entry.

Marks the search index as dirty so it will be rebuilt on next search.

register(entry: CapabilityEntry) -> None

Parameter Type Default Description
entry CapabilityEntry The capability entry to register.

Method CapabilityRegistry.register_from_datasource

Create and register a CapabilityEntry from a DataSource.

Uses source.describe() as the description (if available), otherwise falls back to source.name or the string representation. Reads routing_meta from the source to populate not_for and metadata.

register_from_datasource(source: Any) -> None

Parameter Type Default Description
source Any A DataSource instance with at least a name attribute.

Method CapabilityRegistry.register_from_tool

Create and register a CapabilityEntry from an AbstractTool.

Uses tool.description if available, falling back to tool.name. Reads routing_meta to populate not_for and metadata.

register_from_tool(tool: Any) -> None

Parameter Type Default Description
tool Any An AbstractTool instance with at least name and description attributes.

Method CapabilityRegistry.register_from_yaml

Load and register capability entries from a YAML file.

The YAML file must have a top-level capabilities list. Each item is passed directly to CapabilityEntry(**item).

Example YAML structure::

capabilities:
  - name: product_graph
    description: "Product category graph"
    resource_type: graph_node
    not_for: ["employee data"]

register_from_yaml(path: str) -> None

Parameter Type Default Description
path str Filesystem path to the YAML capability definition file.

Raises:

  • FileNotFoundError — If the path does not exist.
  • ValueError — If the YAML is malformed or missing required fields.

Method CapabilityRegistry.build_index

Compute embeddings for all entries and build the search matrix.

L2-normalises all embedding vectors so cosine similarity can be computed as a simple dot product.

build_index(embedding_fn: Callable) -> None

Parameter Type Default Description
embedding_fn Callable Async callable that accepts list[str] and returns list[list[float]] (one embedding per text).

Method CapabilityRegistry.register_agent_capability

Register one AGENT entry (name=f"{agent_name}::{cap_id}") and index it exactly.

register_agent_capability(agent_name: str, cap_id: str, *, keywords: Sequence[str] = (), category: Optional[str] = None, locality: int = 3, cost: float = 1.0, backing: str = 'llm_backed', kind: str = 'local', metadata: Optional[dict[str, Any]] = None) -> None

Parameter Type Default Description
agent_name str Owning agent name.
cap_id str Dotted capability id (e.g. hr.people.salary).
keywords Sequence[str] () Extra exact-match keywords.
category Optional[str] None Optional category, indexed as a key.
locality int 3 Locality rank (lower is closer).
cost float 1.0 Relative invocation cost.
backing str 'llm_backed' How the capability is backed (llm_backed ...).
kind str 'local' Agent kind (local ...).
metadata Optional[dict[str, Any]] None Extra metadata merged under the standard keys.

Method CapabilityRegistry.unregister_agent

Drop every AGENT entry of agent_name; return the count removed.

unregister_agent(agent_name: str) -> int

Parameter Type Default Description
agent_name str

Returns: int

Method CapabilityRegistry.find_exact

Embedding-free lookup: exact cap_id, glob (hr.people.*), category or keyword (case-insensitive).

find_exact(query: str, *, resource_types: Optional[list[ResourceType]] = None, limit: int = 10) -> list[CapabilityEntry]

Parameter Type Default Description
query str Cap id, glob, category or keyword.
resource_types Optional[list[ResourceType]] None Optional filter on entry resource type.
limit int 10 Maximum entries returned.

Returns: list[CapabilityEntry] — Matching entries in stable (name-sorted) order.

Method CapabilityRegistry.search

Embed the query and return top-K matching capabilities.

Auto-rebuilds the index if dirty (after a new registration) and an embedding function is available.

search(query: str, top_k: int = 5, resource_types: Optional[list[ResourceType]] = None) -> list[RouterCandidate]

Parameter Type Default Description
query str The user query to match against registered capabilities.
top_k int 5 Maximum number of candidates to return.
resource_types Optional[list[ResourceType]] None Optional list of resource types to filter by. If None, all types are considered.

Returns: list[RouterCandidate] — Ranked list of RouterCandidate objects, best match first.

Alias ResourceType

Re-exported from parrot.registry.capabilities.models.ResourceType.

Alias RouterCandidate

Re-exported from parrot.registry.capabilities.models.RouterCandidate.

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