Skip to content

API Reference parrot.bots.flows.core.fsm

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

parrot.bots.flows.core.fsm

View source

Flow Primitives — FSM Module.

Provides AgentTaskMachine (StateMachine subclass) and TransitionCondition enum for state-based agent lifecycle management.

Extracted from parrot.bots.flow.fsm to serve as the shared primitive used by both AgentCrew and AgentsFlow engines.

Class AgentTaskMachine

Finite State Machine describing the lifecycle of a single node execution.

Example::

fsm = AgentTaskMachine(agent_name="researcher")
fsm.schedule()   # idle → ready
fsm.start()      # ready → running
fsm.succeed()    # running → completed
Parameter Type Default Description
agent_name str Human-readable name used in log messages.
**kwargs object {} Forwarded to StateMachine.__init__.

Method AgentTaskMachine.on_enter_running

Called when entering the running state.

on_enter_running() -> None

Method AgentTaskMachine.on_enter_completed

Called when entering the completed state.

on_enter_completed() -> None

Method AgentTaskMachine.on_enter_failed

Called when entering the failed state.

on_enter_failed() -> None

Class TransitionCondition

Predefined conditions that can trigger a flow transition.

Values match the original TransitionCondition in parrot.bots.flow.fsm for backward compatibility.

Attributes:

Attribute Type Description
ON_SUCCESS Transition fires when the source node completes without error.
ON_ERROR Transition fires when the source node raises an exception.
ON_TIMEOUT Transition fires when the source node execution times out.
ON_CONDITION Transition fires when a custom predicate callable returns True.
ALWAYS Unconditional transition — always fires after source node execution.

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