Skip to content

API Reference parrot.core.events.lifecycle.events.tool

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

parrot.core.events.lifecycle.events.tool

View source

Tool lifecycle events.

FEAT-176 — Lifecycle Events System.

Covers: before/after/failed AbstractTool.execute() calls.

Class AfterToolCallEvent

Emitted after AbstractTool._execute() completes successfully.

NOT emitted when _execute() raises (ToolCallFailedEvent is used instead).

Parameter Type Default Description
tool_name str ''
duration_ms float 0.0
result_status str ''
result_size_bytes int 0
compression_codec str ''
compression_level str ''
result_size_bytes_original int 0
compression_duration_ms float 0.0
compression_teed bool False

Fields:

Field Type Default Description
tool_name str '' Name of the tool that was called.
duration_ms float 0.0 Wall-clock time in milliseconds.
result_status str '' "success" or "partial" based on the ToolResult.
result_size_bytes int 0 UTF-8 encoded byte length of the serialized result. FEAT-380: this is now documented as the post-compression size — the tool-result compression pipeline (parrot.tools.compression) may shrink the payload between this event's original emission point and the value a consumer ultimately reads via ToolResult.metadata. See the new compression_* fields below for the pre-compression size and the codec/level/duration/tee outcome. Renamed semantics documented in the FEAT-380 changelog entry.
compression_codec str '' Name of the codec that ran (empty string if compression did not run/was skipped).
compression_level str '' Effective :class:FilterLevel value applied (empty string if compression did not run/was skipped).
result_size_bytes_original int 0 UTF-8 byte length of the result BEFORE compression. Equal to result_size_bytes when compression did not run.
compression_duration_ms float 0.0 Wall-clock time spent in the compression codec, in milliseconds. 0.0 when compression did not run.
compression_teed bool False Whether the original (pre-compression) payload was persisted to working memory for recovery (True for lossy compressions and teed errors).

Class BeforeToolCallEvent

Emitted just before AbstractTool._execute() is called.

Parameter Type Default Description
tool_name str ''
tool_class str ''
args_summary dict dict()

Fields:

Field Type Default Description
tool_name str '' Name of the tool being called.
tool_class str '' Fully-qualified class name of the concrete tool.
args_summary dict field(default_factory=dict) Truncated, JSON-safe dict of call arguments. Strings are truncated at 200 chars; binary/non-primitive values are replaced with type descriptors. Hashing happens at the emission site (AbstractTool.execute), not here.

Class ToolCallFailedEvent

Emitted when AbstractTool._execute() raises an exception.

AfterToolCallEvent is NOT emitted when this fires.

Parameter Type Default Description
tool_name str ''
duration_ms float 0.0
error_type str ''
error_message str ''

Fields:

Field Type Default Description
tool_name str '' Name of the tool that was called.
duration_ms float 0.0 Wall-clock time in milliseconds until failure.
error_type str '' type(exc).__name__ of the exception.
error_message str '' String representation of the exception.

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