apflow
Coordinate workflows.
Inspect each run.
apflow runs dependency-aware workflows locally or across workers. Track task results, submit work durably, and create retry runs with their own history.
What apflow coordinates
Browse capability detailsModel structure and dependencies
Use a task tree for organization and a dependency graph for order, parallel work, and fan-in.
Track acceptance and outcomes
Durable submission records that a Run was accepted. Inspect the stored Run to check completion or start a separate retry.
Scale execution and usage tracking
Start with embedded SQLite or use coordinated PostgreSQL workers. Connect shared token budgets and invocation-level usage where needed.
Run a task with a Python executor
Start with an in-memory SQLite example. Define a Python function as an executor, run one task, and read its stored result.
Install apflow
Install the Python package in your project environment.
Shell python -m pip install apflowDefine and run a task
Save this as run_workflow.py. The task refers to the registered executor by ID.
run_workflow.py import asyncio from apflow.app import create_app from apflow.adapters.function_executor import function_executor @function_executor(id="greet", description="Greet someone") async def greet(inputs: dict) -> dict: return {"message": f"Hello, {inputs['name']}!"} async def main(): app = create_app(connection_string="sqlite:///:memory:") tree = await app.task_creator.create_task_tree_from_array([ {"name": "Say Hello", "inputs": {"name": "World"}, "params": {"executor_id": "greet"}}, ]) await app.task_manager.distribute_task_tree(tree) task = await app.task_repository.get_task_by_id(tree.task.id) print(task.status, task.result) asyncio.run(main())Check the result
Run the script and confirm that the task completed with the greeting result.
Shell python run_workflow.pyExample result completed {'message': 'Hello, World!'}
Documentation
Browse all docsTasks and workflow structure
Understand the task tree, dependencies, executors, and Runs.
Durable submission and retry
Accept work for background execution and inspect or retry an existing Run.
Serve a workflow API
Expose task and Run operations over REST.
Budgets and usage
Set shared token budgets and consume invocation-level usage events.
Detailed capabilities and configuration
Task orchestration
Structure trees organize workflows; dependency DAGs coordinate parallel steps, fan-in, fan-out, and dependency results