Docs de AgentLoom Getting started

Esta documentación solo está disponible en inglés por el momento.

Código abierto · Python · v0.5.0

AgentLoom

Deterministic LLM workflow orchestration with native observability, resilience, and cost control.

Empezar GitHub PyPI
  • DAG-based workflows

    Define workflows as directed acyclic graphs in YAML or Python. Steps, dependencies and routing are declared upfront: the LLM generates text, not control flow.

  • Native observability

    OpenTelemetry traces and Prometheus metrics for every step, and a Grafana dashboard to read them. No external SaaS required.

  • Built-in resilience

    Retries with backoff, timeouts, and a circuit breaker and rate limiter per provider. Checkpoints let a failed or paused run resume where it left off.

  • Cost control

    Tokens and cost tracked for every step, and a budget per workflow: once budget_usd is spent, no further step starts.

Requirements

  • Python 3.11 or newer. AgentLoom supports 3.11 to 3.14.
  • A model to call. An API key for OpenAI, Anthropic or Google, or a local Ollama. No key at all works too: the mock provider answers offline.
  • No provider SDKs. AgentLoom calls each provider’s HTTP API itself, so pip installs nothing from OpenAI, Anthropic or Google.

Installation

Terminal window
pip install agentloom
Terminal window
pip install "agentloom[observability]"

OpenTelemetry and the Prometheus client, for traces and metrics.

Terminal window
pip install "agentloom[graph]"

NetworkX, for the Graph API.

Terminal window
pip install "agentloom[all]"

With extras, keep the quotes: zsh reads unquoted brackets as a file pattern. To check the install, agentloom info prints the version, the Python it runs on, which optional extras are installed and which provider keys are set (never their values).

Quick start

1. Create a workflow — my_workflow.yaml:

name: simple-qa
config:
provider: openai
model: gpt-4o-mini
state:
question: "What is Python in one sentence?"
steps:
- id: answer
type: llm_call
prompt: "Answer this question concisely: {state.question}"
output: answer

One step calls the model with a prompt built from the state, and writes the reply to the answer key.

2. Run it with the provider you have:

Terminal window
export OPENAI_API_KEY=sk-...
agentloom run my_workflow.yaml
Terminal window
export ANTHROPIC_API_KEY=sk-ant-...
agentloom run my_workflow.yaml --provider anthropic --model claude-haiku-4-5-20251001
Terminal window
export GOOGLE_API_KEY=...
agentloom run my_workflow.yaml --provider google --model gemini-2.5-flash
Terminal window
ollama pull phi4
agentloom run my_workflow.yaml --provider ollama --model phi4

Free and local. Ollama must be running (ollama serve) at http://localhost:11434.

Terminal window
agentloom run my_workflow.yaml --provider mock

Every call answers with the placeholder text Mock response: enough to try the CLI and check a workflow’s wiring. Testing & Replay shows how to replay real responses instead.

3. Read the result. The run prints a summary:

Running workflow: simple-qa
============================================================
Workflow: simple-qa
Status: [OK] success
Duration: 812.4ms
Tokens: 41
Cost: $0.0000
Steps:
[OK] answer (809ms)
Final State Keys: ['question', 'answer', 'steps']
============================================================

The summary lists what each step did, not what the model said. To see the answer, ask for the whole result as JSON, or stream the text as it arrives:

Terminal window
agentloom run my_workflow.yaml --json | jq -r .final_state.answer
agentloom run my_workflow.yaml --stream

4. Validate and visualize:

Terminal window
agentloom validate my_workflow.yaml # check the file without running it
agentloom visualize my_workflow.yaml # draw the DAG as text; --format mermaid for a diagram

Keys and providers

  • Keys come from the environment: OPENAI_API_KEY, ANTHROPIC_API_KEY and GOOGLE_API_KEY. AgentLoom reads no .env file, so load one with your shell or a tool like direnv. Each provider whose key is set is available to every step.
  • The model name finds the providers. gpt-*, o1, o3 and o4 models go to OpenAI, claude* to Anthropic, gemini* to Google. --provider says which provider is tried first, if it can serve the model. On a workflow with no model, --provider anthropic brings Anthropic’s default; on one that names a model, pass --model too.
  • Ollama takes no key. It is used when a workflow says provider: ollama (or --provider ollama), and accepts any model name.
  • Endpoints can be changed with OPENAI_BASE_URL, ANTHROPIC_BASE_URL, GOOGLE_BASE_URL and OLLAMA_BASE_URL, for a proxy or a self-hosted gateway. Any other OpenAI-compatible server works through the generic_openai provider.

Providers covers every provider, model and capability.

What a run leaves behind

PathWrittenWhat it is
agentloom_runs/<run_id>.jsonEvery runA record of the run: status, steps, tokens and cost. AGENTLOOM_RUNS_DIR moves it; agentloom history reads it. See run history.
.agentloom/checkpoints/<run_id>.jsonWith --checkpointThe state a run stopped with, which agentloom resume continues from.
Traces and metricsWith the observability extra installedSent over OTLP to OTEL_EXPORTER_OTLP_ENDPOINT (default http://localhost:4317). --lite turns them off. See Observability.

Both directories sit in the current directory: add agentloom_runs/ and .agentloom/ to your .gitignore.

Exit codes

CodeWhen
0The workflow succeeded, or paused at an approval gate.
1The workflow failed, timed out or ran out of budget, or the file did not load.
2The command was misused: a missing file or options that cannot go together.

Scripts and CI jobs can rely on them; --json prints the full result either way.

Common first-run errors

You seeWhyFix
No provider registered for model 'gpt-4o-mini'No key is set for the provider that serves the model.Export the key; agentloom info shows which keys are set.
All providers failed for model … with a 401 or 403The key is wrong or revoked.Check the key in the provider’s console.
All providers failed for model … with a 404The provider doesn’t know the model, often a retired alias.Use one of the recommended model IDs.
A connection error with --provider ollamaOllama isn’t running, or the model isn’t pulled.ollama serve, then ollama pull phi4.
Error loading workflow with Extra inputs are not permittedA key in the YAML is misspelled.agentloom validate names the field.
A prompt shows an empty value, or a literal {name}The template names a state key that doesn’t exist: {state.name} renders empty, {name} stays as written.Check the key against state: and the steps’ output:. See Missing keys.
zsh: no matches found: agentloom[all]The extras aren’t quoted.pip install "agentloom[all]".
Export errors in the log after a runThe observability extra is installed, but no collector listens at the OTLP endpoint.Pass --lite, or start the observability stack.

What’s next

Docs de agentloom 0.5.0. Ver el código fuente de esta página Informar de un problema