Skip to main content

apflow

AI-Perceivable Distributed Orchestration

apflow is a distributed task orchestration engine where every capability is AI-perceivable — discoverable, understandable, and invocable by AI agents through the apcore module standard.

The Tesla Analogy

Think of Tesla's Full Self-Driving (FSD):

Tesla = Traditional car systems (brakes, steering, battery management)
        + FSD (the AI brain that perceives and controls everything)

        The braking system doesn't need to be "smart."
        But it must be perceivable and controllable by FSD.

apflow = Traditional orchestration (dependency graphs, priority scheduling,
         distributed coordination)
        + apcore (makes every capability AI-perceivable)

        Task orchestration doesn't need AI.
        But it must be perceivable and invocable by AI agents.

Tesla doesn't build a competitor to FSD — it builds the best car that FSD can control. apflow doesn't build AI agents — it builds the best orchestration engine that AI agents can invoke.

What apflow IS and IS NOT

apflow IS apflow IS NOT
A distributed orchestration engine An AI agent framework
AI-perceivable via apcore An AI/LLM product
Deterministic, reliable task coordination A competitor to LangGraph/CrewAI
The "car systems" that AI agents control The "FSD brain" itself

Requirements

  • Python >= 3.11

Install

pip install apflow

Quick Start

from apflow import TaskManager, create_session
from apflow.app import create_app

# One line to bootstrap the full stack
app = create_app()

# Start A2A server — AI agents can now discover and invoke orchestration
from apcore_a2a import serve
serve(app.registry, name="apflow")
# Or from the command line
apflow serve              # A2A HTTP server
apflow serve --explorer   # With Explorer UI
apflow serve --all        # Unified REST + A2A + MCP on one port (/, /a2a, /mcp)
apflow worker --db <postgres-url>  # Start distributed worker node (requires PostgreSQL)
apflow rest               # REST/HTTP API + OpenAPI docs at /docs (default :8080)
apflow scheduler          # Run the internal poll-based scheduler (foreground process)
apflow mcp                # MCP server (stdio, for Claude/Cursor)
apflow mcp --transport streamable-http --approval  # HTTP + async human-approval workflow
apflow info               # Show version, config, and registered modules

Core Capabilities

Task Orchestration (Dual Model: Structure Tree + Execution DAG)

apflow uses a dual model — structure tree (parent_id) for organization and execution DAG (dependencies) for ordering. This is not redundancy; each serves different operations:

parent_id    → Structure: copy, link, archive, progress aggregation
dependencies → Execution: parallel scheduling, fan-in, result injection
tasks = [
    {"id": "a", "name": "Step A", "priority": 1},
    {"id": "b", "name": "Step B", "priority": 1},
    {"id": "merge", "name": "Merge", "parent_id": "a", "priority": 2,
     "dependencies": [{"id": "a"}, {"id": "b"}]},  # fan-in: waits for both
]
tree = await task_creator.create_task_tree_from_array(tasks)
await task_manager.distribute_task_tree(tree)

Five Task Creation Modes

Mode Method When to use
Create create_task_tree_from_array() Build a new workflow from scratch
Link from_link() Reference a completed workflow (read-only, low storage)
Copy from_copy() Clone a workflow with modifications (re-run with new params)
Archive from_archive() Freeze an existing completed workflow in place (audit, compliance)
Mixed from_mixed() Partial copy + partial link (re-run only changed steps)

See Task Orchestration Architecture for the full design rationale.

Durable Execution

Checkpoint/resume, retry with configurable backoff, circuit breaker per executor.

Cost Governance

Token budget management, model downgrade chains, policy engine (block/downgrade/notify).

Distributed Coordination

Leader election, task leasing, worker management — scales from single process to multi-node cluster.

AI-Perceivable (via apcore)

Every orchestration capability is automatically exposed as an apcore Module:

  • MCP — AI agents (Claude, Cursor) discover and call orchestration tools
  • A2A — Other services invoke orchestration via HTTP
  • CLI — Humans operate orchestration from the terminal

Architecture

AI Agents / Services / Humans
    ↓ discover & invoke
    ↓
┌──────────────────────────────────────────────┐
│  apflow — AI-Perceivable Distributed         │
│           Orchestration Engine                │
│                                              │
│  ┌── Protocol Exposure (apcore) ───────────┐ │
│  │ apcore-mcp · apcore-a2a · apcore-cli    │ │
│  │              ↕                          │ │
│  │       apcore Registry (Modules)         │ │
│  └──────────────┬──────────────────────────┘ │
│                 │                             │
│  ┌──────────────▼──────────────────────────┐ │
│  │  Orchestration Core                     │ │
│  │  TaskManager · TaskCreator · Scheduler  │ │
│  │  Dependency Graphs · Priority · DAG     │ │
│  ├─────────────────────────────────────────┤ │
│  │  Durability    │  Governance            │ │
│  │  Checkpoint    │  Budget · Policy       │ │
│  │  Retry         │  Model Downgrade       │ │
│  │  Circuit Break │  Usage Reporting       │ │
│  ├─────────────────────────────────────────┤ │
│  │  Infrastructure                         │ │
│  │  SQLite/PostgreSQL · Distributed Runtime│ │
│  │  ConfigManager · Adapters               │ │
│  └─────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘

apcore is not a separate layer — it's embedded inside apflow as the mechanism that makes orchestration capabilities AI-perceivable (like a CAN bus makes car systems perceivable to FSD).

Built-in Executors

Executor Purpose
RestExecutor HTTP/REST API calls (example executor)
AggregateResultsExecutor Combine results from dependency tasks
ApFlowApiExecutor Inter-instance orchestration (cluster)
SendEmailExecutor Email notifications

These are examples and utilities. The real executors are your AI agents, business logic, or any ExecutableTask implementation.

Documentation

Contributing

Contributions welcome. Please open an issue or PR on GitHub.

License

Apache-2.0

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apflow-0.22.0.tar.gz (701.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apflow-0.22.0-py3-none-any.whl (298.9 kB view details)

Uploaded Python 3

File details

Details for the file apflow-0.22.0.tar.gz.

File metadata

  • Download URL: apflow-0.22.0.tar.gz
  • Upload date:
  • Size: 701.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for apflow-0.22.0.tar.gz
Algorithm Hash digest
SHA256 d25ba962099a2f6244d2cc47ccb994bc3fa5b050f9bac06bbfa3524a4dad2521
MD5 d5eb9c2ca41edf0f6eb8253af6f80e9a
BLAKE2b-256 445c6fe440e6fae7d72875ffd777b52491651af5aecc0e1f921da47feb91d7b1

See more details on using hashes here.

File details

Details for the file apflow-0.22.0-py3-none-any.whl.

File metadata

  • Download URL: apflow-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 298.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for apflow-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8878682e6949322d89b5c111a1744a0039a7d3c6d41f52d7616c68bfee64e5ec
MD5 b3f10028848870346ec7b50ba9f208ce
BLAKE2b-256 766eaa6caf557744850ea9fe8ad5efb37450108f2f6164e3f9b499d34688eaa1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.22.1

2 files

This release

0.22.0 This release

2 files

0.18.2

2 files

0.18.1

2 files

0.18.0

2 files

0.17.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.1

2 files

0.12.0

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page