Metadata-Version: 2.4
Name: fable-orchestrator
Version: 0.1.0
Summary: Orchestrate multi-step LLM agent workflows (plan → execute → reflect → finalize) as a typed, replayable state machine.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# fable-orchestrator

`fable-orchestrator` orchestrates multi-step LLM agent workflows — planning, execution, reflection, and tool use — as a typed state machine you can replay and inspect. It pairs naturally with LangChain and Anthropic models, and validates every state transition with Pydantic so a malformed agent run fails loudly instead of silently producing garbage.

It is framework-friendly: bring your own LLM client and tools, define the graph of steps, and `fable-orchestrator` drives execution, persists state, and exposes hooks for checkpoints and human-in-the-loop approvals.

## Features

- Typed state machines for plan → execute → reflect → finalize.
- Pydantic-validated state transitions and tool call schemas.
- First-class LangChain and Anthropic adapters; pluggable model interface.
- Checkpointing to disk, S3, or Redis for resume and replay.
- Human-in-the-loop approval gates with timeouts and escalation.
- Token and cost accounting per step and per run.
- Async-first; supports parallel branches and dynamic fan-out.

## Installation

```bash
pip install fable-orchestrator langchain-anthropic pydantic
```

## Quick start

```python
from fable import Orchestrator, State
from fable.adapters.langchain_anthropic import AnthropicModel

orch = Orchestrator(model=AnthropicModel(model="claude-3-5-sonnet"))

@orch.step("plan")
def plan(state: State) -> State:
    state["plan"] = ["research", "draft", "review"]
    return state

result = orch.run(input="Write a one-pager on liquid cooling for GPUs")
print(result.final, result.usage.total_tokens)
```

## API

- `fable.Orchestrator(model)` — build an orchestrator; `.step(name)` decorator registers a step.
- `orch.run(input, **context)` — execute the state machine and return a `Result`.
- `fable.adapters.langchain_anthropic.AnthropicModel(model=...)` — Anthropic via LangChain.
- `fable.checkpoint(path)` — checkpointer backend passed to the orchestrator.

## Configuration

Set `ANTHROPIC_API_KEY` for the Anthropic adapter, and `FABLE_CHECKPOINT=s3://my-bucket/runs` (or a local path) to enable resume across restarts.

## License

MIT
