Skip to content

API Reference parrot.tools.decorators

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

parrot.tools.decorators

View source

Function requires_permission

Annotate a toolkit method or AbstractTool class with required permissions.

Semantics: ANY of the listed permissions grants access (OR logic). For AND logic, use a single compound permission string.

requires_permission(*permissions: str)

Parameter Type Default Description
*permissions str () Variable permission strings. User needs at least one.

Function tool

Decorator to mark a function as a tool with automatic schema generation.

Automatically extracts:

  • Name from function name (or use custom name)
  • Description from docstring (or use custom description)
  • Input schema from type hints (or use custom schema)

tool(_func: Optional[Callable] = None, *, name: Optional[str] = None, description: Optional[str] = None, schema: Optional[Dict[str, Any]] = None, auto_register: bool = False, requires_confirmation: bool = False, confirm_template: Optional[str] = None, confirm_window_seconds: int = 0, allow_edit: bool = False, required_permissions: Optional[Set[str]] = None)

Parameter Type Default Description
_func Optional[Callable] None
name Optional[str] None Optional custom tool name (defaults to function name)
description Optional[str] None Optional custom description (defaults to docstring)
schema Optional[Dict[str, Any]] None Optional custom input schema (auto-generated from type hints if not provided)
auto_register bool False If True, automatically register with active client/bot
requires_confirmation bool False If True, the tool requires HITL confirmation before execution (via ConfirmationGuard in ToolManager — FEAT-235).
confirm_template Optional[str] None Optional Python format string for the briefing shown to the human. Placeholders: {tool} (tool name), {params} (all params as k=v), plus any individual parameter name. Falls back to a raw tool with: k=v listing when None or on a template error.
confirm_window_seconds int 0 Seconds during which an identical call (same tool, same args_hash) is skipped without re-asking. 0 (default) means always re-ask — the safe per-call default.
allow_edit bool False When True, the human is offered a FORM interaction to edit the parameter values before approving. Edited values are re-validated against the tool's args_schema.
required_permissions Optional[Set[str]] None Optional set of permission strings the caller's PermissionContext must satisfy (via the configured AbstractPermissionResolver) before the tool executes — checked by ToolManager.execute_tool()'s manager-level Layer 2 gate (FEAT-474). Defaults to an empty set (unrestricted).

Function tool_schema

Decorator to specify a custom argument schema for a toolkit method.

tool_schema(schema: Type[BaseModel], description: Optional[str] = None)

Parameter Type Default Description
schema Type[BaseModel]
description Optional[str] None

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