Skip to content

API Reference parrot.bots.flows.plan.facets

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

parrot.bots.flows.plan.facets

View source

Facet extraction — the only thing a model ever learns about a payload.

A facet is a small, structural, cheap-to-compute value pulled out of a tool result before the result is put away in working memory. Facets are what PlanNode.when guards read and what appears in the :class:~.models.ExecutionManifest, so they are also the entire budget for data-dependent control flow. Everything here is bounded by construction: group counts are capped, strings are clipped, and nothing recurses into a payload body.

Attribute MAX_FACET_STR

Function estimate_bytes

Approximate the serialized size of payload.

Used only to surface rehydration cost in the manifest, so an estimate is enough — and it must never raise on an exotic object.

estimate_bytes(payload: Any) -> int

Parameter Type Default Description
payload Any Any tool result.

Returns: int — Approximate size in bytes; 0 when it cannot be measured.

Function extract_facets

Extract facets from one payload.

A path that does not resolve yields no facet rather than a None entry, so a guard reading it fails safe (and the validator is what warns about the typo — see validator._check_guard).

extract_facets(payload: Any, spec: FacetSpec) -> Dict[str, Any]

Parameter Type Default Description
payload Any The tool result.
spec FacetSpec What to extract.

Returns: Dict[str, Any] — A flat {facet_name: value} mapping.

Function merge_facets

Combine per-item facets from a for_each node into one mapping.

Counts sum, group counts merge key-wise (re-capped after merging), and plain paths collapse to the set of distinct values seen — capped, because a per-item path over 3.000 items is not a facet any more.

merge_facets(per_item: Iterable[Mapping[str, Any]], spec: FacetSpec) -> Dict[str, Any]

Parameter Type Default Description
per_item Iterable[Mapping[str, Any]] Facet mappings, one per successfully executed item.
spec FacetSpec The spec they were extracted with.

Returns: Dict[str, Any] — The merged mapping.

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