Metadata-Version: 2.4
Name: py-agent-lib
Version: 0.1.0
Summary: Minimal, domain-agnostic DAG scheduler/executor for step-based workflows.
Project-URL: Homepage, https://github.com/gaslit-ai/py-agent/tree/main/packages/py-agent-lib
Project-URL: Repository, https://github.com/gaslit-ai/py-agent
Project-URL: Issues, https://github.com/gaslit-ai/py-agent/issues
Project-URL: Changelog, https://github.com/gaslit-ai/py-agent/releases?q=lib-v
Author: Vector
License-Expression: MIT
License-File: LICENSE
Keywords: agent,dag,pydantic,scheduler,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: pydantic>=2.6
Requires-Dist: tenacity>=8.2
Provides-Extra: all
Requires-Dist: anthropic>=0.40; extra == 'all'
Requires-Dist: httpx>=0.27; extra == 'all'
Requires-Dist: instructor>=1.5; extra == 'all'
Requires-Dist: litellm>=1.50; extra == 'all'
Requires-Dist: openai>=1.40; extra == 'all'
Requires-Dist: opentelemetry-api>=1.25; extra == 'all'
Requires-Dist: rapidfuzz>=3.6; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.40; extra == 'anthropic'
Requires-Dist: instructor>=1.5; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: anthropic>=0.40; extra == 'dev'
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: hypothesis>=6.0; extra == 'dev'
Requires-Dist: instructor>=1.5; extra == 'dev'
Requires-Dist: litellm>=1.50; extra == 'dev'
Requires-Dist: openai>=1.40; extra == 'dev'
Requires-Dist: opentelemetry-api>=1.25; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.25; extra == 'dev'
Requires-Dist: pyright>=1.1.380; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: rapidfuzz>=3.6; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: fuzzy
Requires-Dist: rapidfuzz>=3.6; extra == 'fuzzy'
Provides-Extra: litellm
Requires-Dist: instructor>=1.5; extra == 'litellm'
Requires-Dist: litellm>=1.50; extra == 'litellm'
Provides-Extra: llm
Requires-Dist: httpx>=0.27; extra == 'llm'
Requires-Dist: instructor>=1.5; extra == 'llm'
Requires-Dist: openai>=1.40; extra == 'llm'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.25; extra == 'otel'
Description-Content-Type: text/markdown

# py-agent-lib

Minimal, domain-agnostic DAG scheduler/executor for step-based workflows. It runs a plan of steps with dependencies, supports cancellation and event streaming, and stays decoupled from any specific domain (LLM, agent, etc.).

## Install

```bash
pip install py-agent-lib
# or
uv add py-agent-lib
```

## 5-minute example

```python
import asyncio
from py_agent_lib import DagExecutor, PlanBuilder, StepStatus, StepResult

builder = PlanBuilder()
builder.add_step(id="pick-files", action="pick")
builder.add_step(id="edit-files", action="edit", deps=["pick-files"])
plan = builder.build()

async def pick(step, ctx):
    return StepResult(step_id=step.id, status=StepStatus.COMPLETED, output=["a.py", "b.py"])

async def edit(step, ctx):
    files = ctx.get_dependency_outputs()["pick-files"]
    return StepResult(step_id=step.id, status=StepStatus.COMPLETED, output={"edited": len(files)})

handlers = {"pick": pick, "edit": edit}

async def main():
    executor = DagExecutor(max_parallel_steps=4)
    state = await executor.execute(plan, handlers)
    print(state.steps["edit-files"].output)

asyncio.run(main())
```

## Status

Alpha. Core API stable, adapters and examples in progress.

## Design

- **Validation everywhere**: Pydantic v2 models at every boundary.
- **Structured concurrency**: `asyncio.TaskGroup` + `graphlib.TopologicalSorter` instead of a hand-rolled scheduler.
- **Retries**: `tenacity` for the heavy lifting.
- **Adapters live outside the core**: LLM clients (Pydantic AI, Instructor), observers (OpenTelemetry, NDJSON), persistence — all separate.
