Skip to content

API Reference parrot.bots.flows.flow.nodes

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

parrot.bots.flows.flow.nodes

View source

flows/flow/nodes.py — Decision + Interactive node types (FEAT-196 / TASK-1311).

Rewrites DecisionFlowNode, InteractiveDecisionNode, and all related types as subclasses of parrot.bots.flows.core.node.Node (frozen Pydantic).

Public symbol names and attribute shapes are preserved exactly from the legacy parrot/bots/flow/decision_node.py and interactive_node.py. Internal implementation adopts NodeResult, FlowContext.shared_data, and build_node_metadata from the canonical parrot.bots.flows.core package.

Mirrors the layout of parrot/bots/flows/crew/nodes.py — single file containing all decision + interactive node types for this subpackage.

Class ApprovalDecision

Approval gate decision schema.

Fields:

Field Type Default Description
decision str The decision value (APPROVE, REJECT, or ESCALATE).
confidence float Confidence level from 0.0 to 1.0.
reasoning str Explanation for the decision.
escalation_reason Optional[str] Optional reason for escalation.

Class BinaryDecision

Binary YES/NO decision schema.

Fields:

Field Type Default Description
decision str The decision value (YES or NO).
confidence float Confidence level from 0.0 to 1.0.
reasoning str Explanation for the decision.

Class DecisionFlowNode

Decision orchestrator node for AgentsFlow workflows.

Rewritten from legacy parrot.bots.flow.decision_node.DecisionFlowNode to subclass parrot.bots.flows.core.node.Node (frozen Pydantic).

NOT an agent itself — a container that orchestrates multiple agents to make decisions. Three operating modes:

  • CIO: Single coordinator agent decides, can escalate to HITL
  • BALLOT: Multiple agents vote, results aggregated with optional weighting
  • CONSENSUS: Agents read each other's decisions, coordinator synthesizes

The frozen Pydantic model stores per-configuration state as fields. Per-run mutable state uses FlowContext.shared_data[self.node_id].

Attributes:

Attribute Type Description
agents Dict[str, Any] Participating agents. Typed as Dict[str, Any] to allow any agent type.
config DecisionNodeConfig
default_question_template str
dependencies Set[str]
successors Set[str]
fsm Optional[AgentTaskMachine]
name str Node identifier (name == node_id for decision nodes).

Method DecisionFlowNode.model_post_init

Auto-create FSM and initialise logger.

model_post_init(__context: Any) -> None

Parameter Type Default Description
__context Any

Method DecisionFlowNode.ask

Execute decision-making process with pre/post action hooks.

Routes to appropriate decision mode handler and returns DecisionResult for transition predicate evaluation.

ask(question: str = '', **ctx: Any) -> DecisionResult

Parameter Type Default Description
question str '' The decision prompt/question.
**ctx Any {} Context from upstream nodes (session_id, user_id, etc.).

Returns: DecisionResult — DecisionResult with final_decision for predicate routing.

Raises:

  • ValueError — If unknown decision mode.
  • RuntimeError — If quorum not met or other execution errors.

Method DecisionFlowNode.execute

Execute the decision node within a FlowContext DAG.

Wraps the ask() result in a NodeResult for uniform handling by the AgentsFlow scheduler.

execute(ctx: FlowContext, deps: DependencyResults, **kwargs: Any) -> NodeResult

Parameter Type Default Description
ctx FlowContext The current flow execution context.
deps DependencyResults Results from completed dependencies.
**kwargs Any {} Extra execution context forwarded to ask().

Returns: NodeResult — NodeResult wrapping the DecisionResult.

Class DecisionMode

Operating mode for decision-making process.

Class DecisionNodeConfig

Configuration for DecisionFlowNode.

Fields:

Field Type Default Description
mode DecisionMode Operating mode (CIO, BALLOT, CONSENSUS).
decision_type DecisionType Type of decision (BINARY, APPROVAL, MULTI_CHOICE, CUSTOM).
decision_schema Optional[type] Pydantic model for structured output.
vote_weight_strategy VoteWeight VoteWeight.EQUAL How to weight votes (for BALLOT/CONSENSUS).
custom_weights Optional[Dict[str, float]] None Custom weight values per agent.
minimum_votes Optional[int] None Minimum number of votes required (quorum).
coordinator_agent_name Optional[str] None Name of coordinator agent (for CONSENSUS).
cross_pollination_rounds int 1 Number of revision rounds (for CONSENSUS).
escalation_policy Optional[EscalationPolicy] None Escalation configuration.
options Optional[List[Dict[str, Any]]] None Available options (for MULTI_CHOICE).

Class DecisionResult

Structured result from a decision node.

Fields:

Field Type Default Description
decision_id str Unique identifier for this decision.
mode DecisionMode The decision mode used (CIO, BALLOT, CONSENSUS).
final_decision Any The actual decision value.
confidence float 1.0 Overall confidence level (0.0 to 1.0).
votes Dict[str, Any] Dict of agent_name -> decision_value.
vote_distribution Dict[str, int] Dict of decision_value -> count.
consensus_level Optional[str] None Consensus level (UNANIMOUS, MAJORITY, etc.).
escalated bool False Whether the decision was escalated to HITL.
escalation_reason Optional[str] None Reason for escalation if applicable.
agent_responses Dict[str, Any] Dict of agent_name -> full response dict.
execution_time float 0.0 Total execution time in seconds.
metadata Dict[str, Any] Additional metadata.

Class DecisionType

Types of decisions the node can make.

Class EscalationPolicy

Defines when and how to escalate to HITL.

Fields:

Field Type Default Description
enabled bool True Whether escalation is enabled.
on_low_confidence Optional[float] Confidence threshold below which to escalate.
on_split_vote bool Whether to escalate on evenly split votes.
on_explicit_keyword bool Whether to escalate when decision is ESCALATE.
hitl_manager Any HumanInteractionManager instance (not serialized).
target_humans List[str] List of human identifiers for escalation.
timeout_seconds float Timeout for HITL response.
fallback_decision Optional[Any] Decision to use if HITL unavailable or times out.

Class InteractiveDecisionNode

A Flow node that asks the user a multiple-choice question in the CLI.

Rewritten from legacy parrot.bots.flow.interactive_node.InteractiveDecisionNode to subclass parrot.bots.flows.core.node.Node (frozen Pydantic).

Instead of using an LLM to decide routing, this node presents a list of options directly to the user in the terminal and returns the selection.

Attributes:

Attribute Type Description
question str
options List[str]
dependencies Set[str]
successors Set[str]
fsm Optional[AgentTaskMachine]
name str Node identifier (name == node_id for interactive nodes).

Method InteractiveDecisionNode.model_post_init

Auto-create FSM and initialise logger.

model_post_init(__context: Any) -> None

Parameter Type Default Description
__context Any

Method InteractiveDecisionNode.ask

Prompt the user in the terminal using questionary.

Ignores the incoming question string, using self.question instead, since this node acts as a static menu prompt.

ask(question: str = '', **ctx: Any) -> DecisionResult

Parameter Type Default Description
question str '' Ignored; self.question is used instead.
**ctx Any {} Execution context forwarded to pre/post actions.

Returns: DecisionResult — DecisionResult with the user's selection in final_decision.

Method InteractiveDecisionNode.execute

Execute the interactive decision node within a FlowContext DAG.

Wraps the ask() result in a NodeResult for uniform handling by the AgentsFlow scheduler.

execute(ctx: FlowContext, deps: DependencyResults, **kwargs: Any) -> NodeResult

Parameter Type Default Description
ctx FlowContext The current flow execution context.
deps DependencyResults Results from completed dependencies.
**kwargs Any {} Extra execution context forwarded to ask().

Returns: NodeResult — NodeResult wrapping the DecisionResult.

Method InteractiveDecisionNode.configure

No-op — nothing to configure.

configure() -> None

Class MultiChoiceDecision

Multi-option choice decision schema.

Fields:

Field Type Default Description
decision str The chosen option key.
confidence float Confidence level from 0.0 to 1.0.
reasoning str Explanation for the decision.
alternatives_considered List[str] List of other options considered.

Class VoteWeight

Pre-defined vote weighting strategies.

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