Skip to main content

Yggdrasil: a Python framework for graph-native agent orchestration

Project description

Yggdrasil - Observable and Explainable Agent-as-Graph library

Build agent systems as graphs, where agents, tools, context, and workflow state live in one runtime.

yggdrasil is a Python framework for graph-native orchestration. The core idea is simple:

  • store agents, tools, prompts, and context as graph nodes
  • connect them with typed edges
  • let the runtime compose and execute that graph at query time

The strongest use case is not just "build an agent." It is:

  • build an agent system that changes over time
  • manage that system as graph data
  • explain why it behaved the way it did

The intended workflow is:

  1. define agents, tools, and context as graph nodes
  2. connect them with typed edges
  3. run queries through the graph
  4. inspect behavior with structured traces and explain_run

Illustration

Yggdrasil

Yggdrasil is named after the world tree because the project is meant to connect distinct realms of work in one traversable system:

  • data and memory
  • humans and approvals
  • deterministic business logic
  • probabilistic reasoning with LLMs
  • durable workflow state across all of them

Start Here

If you are new to the project, use this order:

  1. Start Here
  2. Your First Graph
  3. Choose a Backend
  4. Control Plane Thesis
  5. Explainable Agent Systems
  6. Flagship Workflow
  7. Observability
  8. Visualizer Web UI

Skip these until later:

Install

Requirements: Python 3.11+

Install directly from Git without cloning:

pip install "yggdrasil @ git+https://github.com/hoangdao1/yggdrasil.git"

Add extras the same way:

pip install "yggdrasil[anthropic] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[openai] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[embeddings] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[observe] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[neo4j] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[claude-code] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[viz] @ git+https://github.com/hoangdao1/yggdrasil.git"
pip install "yggdrasil[dev] @ git+https://github.com/hoangdao1/yggdrasil.git"

Or clone the repo for local development:

git clone https://github.com/hoangdao1/yggdrasil.git
cd yggdrasil
pip install -e .

Add the extras you need:

pip install -e ".[anthropic]"    # default Anthropic backend
pip install -e ".[openai]"       # OpenAI-compatible backend
pip install -e ".[embeddings]"   # semantic retrieval
pip install -e ".[observe]"      # OpenTelemetry export
pip install -e ".[neo4j]"        # Neo4j graph store
pip install -e ".[claude-code]"  # Claude Code sub-agent backend
pip install -e ".[viz]"          # browser trace visualizer
pip install -e ".[dev]"          # tests + rich trace UI

Fastest Working Example

90% of use cases fit in five lines. The beginner-friendly path uses GraphApp, which wires up the store, executor, and backend automatically.

import asyncio
from yggdrasil_lm.app import GraphApp


async def main() -> None:
    app = GraphApp()
    agent = await app.add_agent("Bot", system_prompt="You are a helpful assistant.")
    ctx = await app.run(agent, "What is Python 3.13?")
    print(ctx.outputs[agent.node_id]["text"])


asyncio.run(main())

Need tools? Attach the built-ins and go:

import asyncio
from yggdrasil_lm.app import GraphApp


async def main() -> None:
    app = GraphApp()

    agent = await app.add_agent(
        "Researcher",
        system_prompt="You are a technical researcher.",
        model="claude-sonnet-4-6",
    )
    app.use_default_tools()  # registers built-in web_search, echo, run_python

    ctx = await app.run(agent, "What changed in Python 3.13?")
    print(ctx.outputs[agent.node_id]["text"])


asyncio.run(main())

Want local Claude Code sub-agents instead of a hosted API backend?

from yggdrasil_lm.app import GraphApp

app = GraphApp(
    provider="claude-code",
    cwd="/path/to/project",
    permission_mode="acceptEdits",
)

This uses your Claude Code executor setup and can bridge graph ToolNodes into the sub-agent as in-process MCP tools.

See API reference §2 Builder API for the full GraphApp surface, including add_tool(fn=..., attach=True, agent=...), add_context, add_prompt, and delegate.

Why This Project Exists

Many agent systems start as prompt-and-tool loops, then become operational systems:

  • new policies appear
  • review steps are added
  • context sources change
  • capabilities vary by tenant or environment
  • operators need to explain decisions

yggdrasil is designed for that phase.

It treats the agent system as something that should be:

  • versioned
  • diffed
  • migrated
  • inspected
  • explained

Core Mental Model

Keep these four ideas in mind:

  1. Composition is traversal. Agents discover tools, prompts, and context by following graph edges.

  2. Execution is traversal. Running a query is a walk through the graph.

  3. Routing is explicit. Multi-agent handoff is represented in the graph and resolved by the executor.

  4. Outputs can become graph state. Runs produce traces and can materialize runtime context.

API Layers

There are two ways to use the project.

Beginner API

Use this first. Import from yggdrasil.app:

  • GraphApp
  • create_agent()
  • create_tool()
  • create_context()
  • create_prompt()
  • create_executor()

Low-Level Runtime API

Use this when you need direct control:

  • AgentNode, ToolNode, ContextNode, PromptNode
  • Edge
  • NetworkXGraphStore
  • GraphExecutor

What The Project Already Does Well

  • dynamic tool and context composition from graph edges
  • multi-agent routing
  • sequential, fan-out, and DAG execution strategies
  • batch execution with concurrency, checkpointing, and resume
  • structured traces with terminal and browser views
  • typed run explanations with hop summaries, routing decisions, and tool call details
  • workflow runtime features such as pause/resume, approvals, and checkpoints

For the browser trace viewer specifically, see Visualizer Web UI.

Recommended Learning Path

Learn the runtime

Run practical local examples

Learn provider setup

Learn the platform layer

Contributor Docs

Reference Docs

Project Status

This repo now has a clearer split:

  • README.md: first-run path
  • docs/: tutorials, architecture, and operations
  • API_REFERENCE.md: exhaustive reference
  • yggdrasil/app.py: beginner-facing builder API
  • yggdrasil/core/: low-level runtime

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yggdrasil_lm-0.1.3.tar.gz (130.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yggdrasil_lm-0.1.3-py3-none-any.whl (119.7 kB view details)

Uploaded Python 3

File details

Details for the file yggdrasil_lm-0.1.3.tar.gz.

File metadata

  • Download URL: yggdrasil_lm-0.1.3.tar.gz
  • Upload date:
  • Size: 130.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for yggdrasil_lm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a2b9f8af6b21f8f507f81a26417caf4c425c85f5bf29204e7152e737ea8b8237
MD5 1196c7dfd0e5a6f699dfbf20a4a862d7
BLAKE2b-256 418993bfe508e452ceb279a676ac1b6fd7374a06d69e4e487bede7e5f9f30b03

See more details on using hashes here.

File details

Details for the file yggdrasil_lm-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: yggdrasil_lm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 119.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for yggdrasil_lm-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 29e811f460a11139823ef8ac0400851d42e59b633241f86d73e68244abc0c630
MD5 4d875729b1eeb2c93dd4744131680a75
BLAKE2b-256 24e95fc8eeb8d0f571be69817a145378786d2fca904b3ee8ac459fca3de9fe48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page