Skip to content

API Reference parrot.skills.tenancy

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

parrot.skills.tenancy

View source

Per-tenant skill primitives (FEAT-707).

Tenant-id validation, secure tenant paths, per-task ContextVars and the read-only :class:SkillView overlay of a tenant registry over the global one.

Class ActiveSkillScope

Opaque token pair returned by :func:enter_active_skill_scope.

Attributes:

Attribute Type Description
active Token
turn Token

Alias RESERVED_TENANT_NAMES

Re-exported from parrot.utils.tenancy.RESERVED_TENANT_NAMES.

Attribute SKILLS_DIRNAME

Type: Final[str]

Alias SkillDefinition

Re-exported from parrot.skills.models.SkillDefinition.

Alias SkillFileRegistry

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

Class SkillView

Read-only overlay of a tenant registry over the global registry.

Parameter Type Default Description
global_registry SkillFileRegistry
tenant_registry Optional[SkillFileRegistry] None
tenant Optional[str] None
logger Optional[logging.Logger] None

Attributes:

Attribute Type Description
report Optional[TenantTreeReport]
learned_dir Path Return the global learned directory; learned skills are global.

Method SkillView.compose

Recompute the effective indexes for collision cases C1 through C8.

compose() -> 'SkillView'

Returns: 'SkillView'

Method SkillView.get

Return the skill matching trigger in this view.

get(trigger: str) -> Optional[SkillDefinition]

Parameter Type Default Description
trigger str

Returns: Optional[SkillDefinition]

Method SkillView.get_by_name

Return the skill named name in this view.

get_by_name(name: str) -> Optional[SkillDefinition]

Parameter Type Default Description
name str

Returns: Optional[SkillDefinition]

Method SkillView.list_skills

Return effective skills: tenant first, then unshadowed globals.

list_skills() -> List[SkillDefinition]

Returns: List[SkillDefinition]

Method SkillView.has_trigger

Return whether trigger resolves in this view.

has_trigger(trigger: str) -> bool

Parameter Type Default Description
trigger str

Returns: bool

Attribute TENANTS_DIRNAME

Type: Final[str]

Class TenantTreeReport

Configure-time audit of one tenant tree.

Parameter Type Default Description
tenant str
skills_dir Path
loaded int
shadowing tuple[str, ...] ()
shadowed_triggers tuple[str, ...] ()
dropped tuple[str, ...] ()

Fields:

Field Type Default Description
tenant str
skills_dir Path
loaded int
shadowing tuple[str, ...] ()
shadowed_triggers tuple[str, ...] ()
dropped tuple[str, ...] ()

Alias bind_request_tenant

Re-exported from parrot.utils.tenancy.bind_request_tenant.

Function bind_skill_tenant

Bind tenant for the current task and return its reset token.

bind_skill_tenant(tenant: Optional[str]) -> Token

Parameter Type Default Description
tenant Optional[str]

Returns: Token

Function current_active_skill

Return the request-local trigger-activated skill, if any.

current_active_skill() -> Optional[SkillDefinition]

Returns: Optional[SkillDefinition]

Alias current_request_tenant

Re-exported from parrot.utils.tenancy.current_request_tenant.

Function current_skill_tenant

Return the tenant bound to the current asyncio task, if any.

current_skill_tenant() -> Optional[str]

Returns: Optional[str]

Alias current_tenant

Re-exported from parrot.observability.context.current_tenant.

Function current_turn_skill

Return the skill a /trigger activated during this turn, even after the prompt consumed it (FEAT-752).

current_turn_skill() -> Optional[SkillDefinition]

Returns: Optional[SkillDefinition]

Function discover_tenant_dirs

Return valid tenant skill directories, ordered by tenant name.

Invalid names, escaping symlinks, and entries without a skills directory are skipped with a warning. A missing tenant root returns an empty mapping.

discover_tenant_dirs(agent_root: Path, logger: Optional[logging.Logger] = None) -> Dict[str, Path]

Parameter Type Default Description
agent_root Path
logger Optional[logging.Logger] None

Returns: Dict[str, Path]

Function enter_active_skill_scope

Snapshot the active and turn skills so :func:exit_active_skill_scope can restore both.

ask()/ask_stream() open this scope so a skill a /trigger set during a call never outlives that call, even when the call fails before the system prompt consumes it.

enter_active_skill_scope() -> ActiveSkillScope

Returns: ActiveSkillScope

Function exit_active_skill_scope

Restore the skills captured by :func:enter_active_skill_scope.

exit_active_skill_scope(token: ActiveSkillScope) -> None

Parameter Type Default Description
token ActiveSkillScope

Function isolated_skill_scope

Hide the request's active skill from an internal LLM call, then restore it.

A nested invoke()/ask() builds its own system prompt, which would otherwise consume the skill before the user's request gets it.

isolated_skill_scope() -> Iterator[None]

Returns: Iterator[None]

Alias reset_request_tenant

Re-exported from parrot.utils.tenancy.reset_request_tenant.

Function reset_skill_tenant

Undo a prior :func:bind_skill_tenant call.

reset_skill_tenant(token: Token) -> None

Parameter Type Default Description
token Token

Alias secure_path

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

Function set_active_skill

Replace the request-local active skill; a non-None skill is also recorded as the turn skill.

set_active_skill(skill: Optional[SkillDefinition]) -> None

Parameter Type Default Description
skill Optional[SkillDefinition]

Function tenant_skills_dir

Return the contained agent_root/tenants/{tenant}/skills path.

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

Parameter Type Default Description
agent_root Path
tenant str

Returns: Path

Raises:

  • ValueError — If the tenant is invalid or the resolved path escapes agent_root.

Alias validate_tenant_id

Re-exported from parrot.utils.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