Skip to content

API Reference parrot.skills.prompt

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

parrot.skills.prompt

View source

Skills Prompt Layer Factory.

Provides :func:render_skills_prompt_layer — a factory function that builds a static <available_skills> XML block from a :class:~parrot.skills.file_registry.SkillFileRegistry and returns it as an immutable :class:~parrot.bots.prompts.PromptLayer with phase=RenderPhase.CONFIGURE.

The layer is resolved once at configure() time and cached, incurring zero per-turn cost (Tier 1 of the two-tier skills system).

Usage::

from parrot.skills.prompt import render_skills_prompt_layer

layer = render_skills_prompt_layer(registry)
self._prompt_builder.add(layer)

Alias PromptLayer

Re-exported from parrot.bots.prompts.PromptLayer.

Alias RenderPhase

Re-exported from parrot.bots.prompts.RenderPhase.

Attribute TenantResolver

Function build_active_skill_layer

Build the trailing conditional skill-body layer with explicit cache eligibility.

build_active_skill_layer(priority: int = 90, *, cacheable: bool = False) -> PromptLayer

Parameter Type Default Description
priority int 90
cacheable bool False

Returns: PromptLayer

Alias current_skill_tenant

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

Function global_layer_condition

Return a condition true when the current tenant is not a known tenant.

global_layer_condition(known_tenants: Collection[str], resolver: Optional[TenantResolver] = None) -> Callable[[Dict[str, Any]], bool]

Parameter Type Default Description
known_tenants Collection[str] Tenants with their own layer (a live collection is fine).
resolver Optional[TenantResolver] None Returns the current tenant; see :func:tenant_layer_condition.

Returns: Callable[[Dict[str, Any]], bool]

Function render_skills_prompt_layer

Build a static <available_skills> XML PromptLayer from the registry.

Reads all skills from registry and emits an XML block listing each skill's name, description, and a load_skill(name="...") hint. Skills that declare triggers also include an "Also triggerable via: /cmd" line.

The returned :class:~parrot.bots.prompts.PromptLayer uses phase=RenderPhase.CONFIGURE so it is resolved once at boot and cached; there is no per-request evaluation overhead.

render_skills_prompt_layer(registry: Any, max_skills: Optional[int] = None, priority: int = 45, *, name: str = 'available_skills', phase: RenderPhase = RenderPhase.CONFIGURE, condition: Optional[Callable[[Dict[str, Any]], bool]] = None, cacheable: Optional[bool] = None) -> PromptLayer

Parameter Type Default Description
registry Any Any object exposing list_skills(), such as a :class:~parrot.skills.file_registry.SkillFileRegistry or :class:~parrot.skills.tenancy.SkillView.
max_skills Optional[int] None If set, truncate to this many skills (first N from registry). None means include all.
priority int 45 Integer priority for the layer. Default 45 places the layer between USER_SESSION (40) and TOOLS (50).
name str 'available_skills' Name for the returned prompt layer. Defaults to "available_skills".
phase RenderPhase RenderPhase.CONFIGURE Rendering phase for the layer. Defaults to RenderPhase.CONFIGURE.
condition Optional[Callable[[Dict[str, Any]], bool]] None Optional callable that controls whether the layer renders.
cacheable Optional[bool] None Optional explicit provider-cache eligibility override.

Returns: PromptLayer — A frozen :class:~parrot.bots.prompts.PromptLayer with: - name="available_skills" by default - template containing the <available_skills> XML block, or an empty string if the registry has no skills. - phase=RenderPhase.CONFIGURE by default - literal=True: skill names, descriptions and triggers are author-supplied text, so a $name in them is never substituted.

Function tenant_layer_condition

Return a condition true only while tenant is the current tenant.

tenant_layer_condition(tenant: str, resolver: Optional[TenantResolver] = None) -> Callable[[Dict[str, Any]], bool]

Parameter Type Default Description
tenant str The tenant this layer belongs to.
resolver Optional[TenantResolver] None Returns the current tenant. Defaults to :func:~parrot.skills.tenancy.current_skill_tenant (the bound ContextVar only); SkillRegistryMixin passes one that also falls back to the bot's default tenant_id.

Returns: Callable[[Dict[str, Any]], bool]

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