Pure Python implementation of the motosan-agent-workflow SDK
Project description
motosan-agent-workflow (Python)
A general-purpose DAG-based agent workflow engine for orchestrating LLM agents.
Installation
pip install motosan-agent-workflow
# Optional YAML support:
pip install "motosan-agent-workflow[yaml]"
Quick Start
import asyncio
from motosan_agent_workflow import (
Workflow, Node, Runtime, LlmClient, LlmResponse,
)
class MyLlm(LlmClient):
async def call(self, system_prompt: str, input_data: dict, tools: list[str]) -> LlmResponse:
return LlmResponse(content={"answer": "..."}, input_tokens=100, output_tokens=50)
async def main():
workflow = (
Workflow.builder("my-pipeline")
.node(Node.agent("researcher", system_prompt="Find key facts about the topic."))
.node(Node.agent("writer", system_prompt="Write a report.", input_from=["researcher"]))
.edge("researcher", "writer")
.build()
)
runtime = Runtime(MyLlm())
result = await runtime.execute(workflow, {"topic": "Python in 2026"})
print(result.node_output("writer").content)
asyncio.run(main())
YAML Workflow
from motosan_agent_workflow import load_workflow, load_workflow_from_str, Format
# From file
workflow = load_workflow("my-workflow.yaml")
# From string
workflow = load_workflow_from_str(yaml_str, Format.YAML)
Node Types
| Type | Description | LLM |
|---|---|---|
Node.agent() |
LLM-powered agent | Yes |
Node.human() |
Human-in-the-loop gate | No |
Node.transform() |
Pure function transform | No |
Node.condition() |
Conditional branching | No |
Node.loop_node() |
Iterative loop | Depends |
Node.sub_workflow() |
Nested sub-workflow | Depends |
Features
- Parallel execution — Nodes in the same DAG layer run concurrently via
asyncio.gather - Output schema validation — JSON Schema with auto self-correction
- Retry policies — Per-node exponential backoff with Skip/Abort/Fallback modes
- Human-in-the-loop — Gates with timeout and default action
- Event streaming —
WorkflowEventvia async callback - Token tracking — Per-node and total, with budget enforcement
- Cost estimation — Pre-execution cost estimates with configurable pricing
- YAML/JSON loader —
load_workflow()andload_workflow_from_str() - 8 built-in templates — code-review, research, brainstorm, report, playlist, content, architecture-review, sprint-planning
Requirements
- Python >= 3.10
- Optional:
pyyaml >= 6.0for YAML support
Publishing
git tag python-v0.3.0
git push origin python-v0.3.0
# → triggers publish-python.yml → PyPI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file motosan_agent_workflow-0.3.0.tar.gz.
File metadata
- Download URL: motosan_agent_workflow-0.3.0.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4fdb824fc9faef4cf58d42d301e23c957b1c6debdf753db6511f537b18230db
|
|
| MD5 |
5118c7ff99ab9f51f331c0597f0004c6
|
|
| BLAKE2b-256 |
069870fd8d0bf746a32f799501422e9d047354e21d700851e7821af8389d2916
|
File details
Details for the file motosan_agent_workflow-0.3.0-py3-none-any.whl.
File metadata
- Download URL: motosan_agent_workflow-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
462fc6b50069f986aba81bc00d89d48abf80950ce34acf929de2f7ec5070de88
|
|
| MD5 |
a2192f0eadee63a9e22344c122f78663
|
|
| BLAKE2b-256 |
3c2225840b047f2e6792d114c786cd2131f49e5c89bb30a4e65ab91ffc90e02a
|