Skip to content

API Reference parrot.skills.middleware

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

parrot.skills.middleware

View source

Skill trigger middleware for the prompt pipeline.

Factory function that creates a PromptMiddleware detecting /trigger patterns at the start of user messages, stripping the prefix, setting the activated SkillDefinition on the bot instance, and handling reserved /skills and /help triggers.

Alias AbstractBot

Re-exported from parrot.bots.abstract.AbstractBot.

Alias PromptMiddleware

Re-exported from parrot.bots.middleware.PromptMiddleware.

Alias SkillFileRegistry

Re-exported from parrot.skills.file_registry.SkillFileRegistry.

Function create_skill_trigger_middleware

Create a PromptMiddleware that detects /trigger patterns.

The middleware intercepts user messages starting with /, looks up the trigger in the registry, and if found:

  • Sets the request-local active skill to the matching SkillDefinition
  • Preserves bot._active_skill for legacy bot implementations
  • Returns the remaining text after the trigger

Reserved triggers /skills and /help return a formatted listing of available skills.

create_skill_trigger_middleware(registry: SkillFileRegistry, bot: AbstractBot, priority: int = -10, *, view_provider: Optional[Callable[[], Any]] = None) -> PromptMiddleware

Parameter Type Default Description
registry SkillFileRegistry The SkillFileRegistry to look up triggers in.
bot AbstractBot The bot instance — used to set _active_skill via closure.
priority int -10 Middleware priority (lower runs first). Default -10.
view_provider Optional[Callable[[], Any]] None Optional callable returning the current per-request SkillView (FEAT-707). The constructor registry is used when it returns None or is not provided.

Returns: PromptMiddleware — A configured PromptMiddleware instance.

Alias current_active_skill

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

Alias detect_trigger

Re-exported from parrot.skills.resolver.detect_trigger.

Alias set_active_skill

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

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