Skip to content

API Reference parrot.tools.execution_gates

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

parrot.tools.execution_gates

View source

Execution gates of :class:AbstractTool (FEAT-622 M3b/M4/M8) — kept out of abstract.py on purpose.

Everything here runs before a tool does any work: the tenant scope gate, the approval token check, the server-managed argument drop/fill and the subclass/constructor refusals. AbstractTool.execute calls these helpers; the public import paths (parrot.tools.abstract, parrot.auth.confirmation) are unchanged.

Alias AbstractTool

Re-exported from parrot.tools.abstract.AbstractTool.

Class ServerManagedToolkit

Mixin of AbstractToolkit (FEAT-622 M3b/M4): declared server params and the scope-gated config_options.

Attributes:

Attribute Type Description
server_managed_params Mapping[str, ServerParam]

Alias ServerParam

Re-exported from parrot.tools.server_params.ServerParam.

Alias ToolResult

Re-exported from parrot.tools.abstract.ToolResult.

Alias ToolScopeUnavailable

Re-exported from parrot.tools.scope.ToolScopeUnavailable.

Function check_approval

Refuse a confirmation_enforced tool unless ToolManager approved exactly this call (FEAT-622 M8).

Only the ContextVar token set by ToolManager after a confirmed guard decision counts: it must name this tool instance and the hash of the kwargs received here. Never a kwarg, never an instance flag.

check_approval(tool: 'AbstractTool', kwargs: Dict[str, Any]) -> Optional['ToolResult']

Parameter Type Default Description
tool 'AbstractTool'
kwargs Dict[str, Any]

Returns: Optional['ToolResult'] — A forbidden ToolResult (error_code="confirmation_required"), or None when allowed.

Function checked_args_schema

The method's custom _args_schema (or None); TypeError when it exposes a server-managed name.

checked_args_schema(toolkit: Any, bound_method: Any, name: str) -> Any

Parameter Type Default Description
toolkit Any
bound_method Any
name str

Returns: Any

Function checked_executor

executor unchanged; TypeError when a tenant-bound toolkit carries a remote executor.

checked_executor(toolkit: Any, executor: Any) -> Any

Parameter Type Default Description
toolkit Any
executor Any

Returns: Any

Function drop_server_managed

Drop kwargs naming a server-managed method param (the LLM never sets them), with one warning.

drop_server_managed(tool: 'AbstractTool', kwargs: Dict[str, Any]) -> Dict[str, Any]

Parameter Type Default Description
tool 'AbstractTool'
kwargs Dict[str, Any]

Returns: Dict[str, Any]

Function enforce_scope_and_approval

Scope gate for EVERY tenant-bound tool (with or without scope-sourced params), then the approval token.

Runs before the permission resolver, lifecycle events, _ensure_open, validation and _execute.

enforce_scope_and_approval(tool: 'AbstractTool', kwargs: Dict[str, Any]) -> Optional['ToolResult']

Parameter Type Default Description
tool 'AbstractTool'
kwargs Dict[str, Any]

Returns: Optional['ToolResult']

Function gate_options

Wrap a tenant-bound toolkit's config_options (plain, class- or staticmethod) with the scope gate.

The gate runs before the original acquires anything, so a direct call outside a valid scope never reaches it.

gate_options(raw: Any, owner_name: str) -> Any

Parameter Type Default Description
raw Any
owner_name str

Returns: Any

Function inject_server_managed

Fill tenant / caller / agent method params from the bound studio_scope (per call).

inject_server_managed(tool: 'AbstractTool', resolved: Dict[str, Any]) -> Dict[str, Any]

Parameter Type Default Description
tool 'AbstractTool'
resolved Dict[str, Any]

Returns: Dict[str, Any]

Alias is_tenant_bound

Re-exported from parrot.tools.scope.is_tenant_bound.

Function mark_host_write

Host standalone write tools are strictly confirmed and approvable via ToolManager (FEAT-622 M8).

mark_host_write(tool: 'AbstractTool') -> None

Parameter Type Default Description
tool 'AbstractTool'

Alias method_server_params

Re-exported from parrot.tools.server_params.method_server_params.

Function pre_execute_refusal

Scope gate, approval check (FEAT-622) then the Layer 2 permission safety net; None when all allow.

pre_execute_refusal(tool: 'AbstractTool', kwargs: Dict[str, Any], pctx: Any, resolver: Any) -> Optional['ToolResult']

Parameter Type Default Description
tool 'AbstractTool'
kwargs Dict[str, Any]
pctx Any
resolver Any

Returns: Optional['ToolResult']

Function refuse_remote_executor

A tenant-bound tool (or toolkit) never runs on a remote worker: the scope lives in this process only.

refuse_remote_executor(tool: object, executor: object) -> None

Parameter Type Default Description
tool object
executor object

Function require_run_gate

The gates of execute for a caller that bypasses it (tool.run / direct dispatch): raise on refusal.

require_run_gate(tool: 'AbstractTool', kwargs: Dict[str, Any]) -> None

Parameter Type Default Description
tool 'AbstractTool'
kwargs Dict[str, Any]

Raises:

  • ToolScopeUnavailable — a tenant-bound tool with no valid scope.
  • PermissionError — a confirmation-enforced write without an approval token.

Alias require_tool_scope

Re-exported from parrot.tools.scope.require_tool_scope.

Function scope_metadata

Result metadata of a failed call; a :class:ToolScopeUnavailable carries its stable code and reason.

scope_metadata(tool: 'AbstractTool', exc: BaseException) -> Dict[str, Any]

Parameter Type Default Description
tool 'AbstractTool'
exc BaseException

Returns: Dict[str, Any]

Function scope_refusal

The structured tool_scope_unavailable refusal (never an exception to the agent loop).

scope_refusal(tool: 'AbstractTool', exc: ToolScopeUnavailable) -> 'ToolResult'

Parameter Type Default Description
tool 'AbstractTool'
exc ToolScopeUnavailable

Returns: 'ToolResult'

Function server_param_owner

The class declaring the tool's server_managed_params: the owning toolkit for a ToolkitTool.

server_param_owner(tool: 'AbstractTool') -> type

Parameter Type Default Description
tool 'AbstractTool'

Returns: type

Function toolkit_server_params

Server-managed method params of the toolkit owning bound_method (never offered to the LLM).

toolkit_server_params(bound_method: Any) -> Dict[str, ServerParam]

Parameter Type Default Description
bound_method Any

Returns: Dict[str, ServerParam]

Alias validate_custom_args_schema

Re-exported from parrot.tools.server_params.validate_custom_args_schema.

Alias validate_server_params

Re-exported from parrot.tools.server_params.validate_server_params.

Function validate_tool_subclass

AbstractTool.__init_subclass__ body: declared server params and custom args_schema are validated.

validate_tool_subclass(cls: type) -> 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