Skip to main content

LangGraph abstractions for hierarchical multi-agent systems

Project description

langgraph-hierarchies

Decomposable agent hierarchies for LangGraph.

Documentation: https://korrino222.github.io/langgraph-hierarchies/

Status: early development (0.0.x). API and scope are not stable. v0.1 will ship the keystone slice below.

An agentic system is decomposable when it can be split into finer agentic systems — each developed, run, and evaluated in isolation, with its own context — that still achieve the goal of the whole. Decomposability in AI workflows explains why that matters: lean context per unit, benchmarkable seams, durable checkpoints, and improvements that stop colliding across stages.

langgraph-hierarchies is the library for building that on LangGraph: recursive hierarchies of real compiled subgraphs, with declarative per-subchain context isolation (SubchainPolicy), supervisor-controlled iteration budgets, and artifact handoff across boundaries — not one swelling monolith, not ephemeral task-tool isolation alone.

Flat delegation (supervisor handoffs, Deep Agents) is a good starting point. This library targets the production wall past that: invokable subagents that nest as deep as the problem needs while preserving streamability, durability, and resumability at every level.

How this relates to other libraries

langgraph-supervisor Deep Agents langgraph-hierarchies
Model Supervisor → workers (handoff tools) Harness + subagents (task / programmatic task()) Class-as-factory graphs, phased compile, SubchainPolicy
Context isolation Shared parent history Ephemeral subagent context Declarative clear/merge/discard per subchain boundary
Nesting Multi-level supervisors Fan-out / data recursion (partial); not stateful deep trees Recursive compiled subgraphs + explicit state policy
Best for Quick hierarchical routing General long-horizon agents Production decomposable hierarchies — benchmarkable units, lean checkpoints

Deep Agents already covers fan-out, parallel orchestration, and RLM-style recursion over data (programmatic subagents, June 2026). This project does not try to replace that.

See examples/irs_reporting/ for a five-stage pipeline with artifact-only handoff between compiled subgraphs — the IRS workflow from the article, decomposed.

Compatibility

langgraph-hierarchies langgraph
0.0.x 1.2.6 (pinned; see releases)

Regression tests gate version bumps. A pair is listed here only once the full suite is green for it.

Bumping the langgraph pin

  1. Update the langgraph constraint in pyproject.toml.
  2. Refresh the lockfile: uv sync.
  3. Run the full suite: uv run pytest.
  4. To isolate a failing story, run e.g. uv run pytest -m us04.
  5. When the suite is green, update the compatibility matrix above and cut a release.

CI runs ruff and pytest on every push/PR (Python 3.10–3.13). Tests use scripted models only — no LLM API keys required.

What's in 0.0.3

  • LangSmith threads — automatic thread_id normalization into RunnableConfig metadata at invoke time (see below)

What's in 0.0.2

The mechanics behind decomposable hierarchies:

  • BaseGraph / CompiledGraph + phased compilation — each unit is a real invokable subgraph
  • SubchainPolicy — entry snapshot, clear/merge/discard, exit restore; isolate context at every seam
  • ReactGraph + iteration safety — per-agent limits, supervisor task_iterations, forced-exit report
  • Root compile (compile_as_root) and unified invocation — stream and checkpoint through the full tree
  • Compatibility harness (per-story pytest markers, CI) — benchmark units in isolation
  • TodoGraph + todo toolkit — batch processing with flat context; IRS hierarchy example (examples/irs_reporting/)

Planner/Executor, progress tracking, HITL: follow-on after v0.1.

LangSmith threads

LangSmith groups multi-turn conversations when runs share metadata.thread_id (or session_id). The library normalizes thread IDs automatically at invoke time. Provide any one of:

  • config["configurable"]["thread_id"] — LangGraph checkpoint convention
  • config["metadata"]["thread_id"] — explicit LangSmith thread
  • context.thread_id on your context dataclass (e.g. BaseContext)

All three are backfilled when missing. Explicit metadata.thread_id is never overwritten.

from langgraph_hierarchies import BaseContext, build_invoke_config

config = build_invoke_config(thread_id="demo-run-1", recursion_limit=200)
result = root.invoke(state, config=config, context=BaseContext(model=model))

With LANGCHAIN_TRACING_V2=true, open your project → Threads tab and filter by the thread ID. Child subgraph spans inherit the same config via LangGraph propagation.

Install

pip install langgraph-hierarchies

Requires Python ≥3.10 (matches LangGraph).

Development

Uses uv (same toolchain as upstream LangGraph):

uv sync
uv run pytest
uv build   # sdist + wheel for PyPI

Disclaimer

This project is not affiliated with, endorsed by, or maintained by LangChain or the LangGraph team. “LangGraph” is a trademark of LangChain; this package name indicates compatibility with the LangGraph runtime, not official status.

Contact

License

MIT — see LICENSE.

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

langgraph_hierarchies-0.0.3.tar.gz (57.3 MB view details)

Uploaded Source

Built Distribution

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

langgraph_hierarchies-0.0.3-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_hierarchies-0.0.3.tar.gz.

File metadata

  • Download URL: langgraph_hierarchies-0.0.3.tar.gz
  • Upload date:
  • Size: 57.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for langgraph_hierarchies-0.0.3.tar.gz
Algorithm Hash digest
SHA256 41ccb9a015eed804630d65ba430835689af237b2a3e5846cf50309c6c7013ade
MD5 8d3b58b3daa13660f6d34259ada1d2a7
BLAKE2b-256 00a471fca89bf029c0500d28b989d4d1521c9c72ee3a0544beee4ca2a92a22e7

See more details on using hashes here.

File details

Details for the file langgraph_hierarchies-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: langgraph_hierarchies-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for langgraph_hierarchies-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 726561f784f4344798c77635d51af7368a2b844f3af576ae5405e8bf0b64279a
MD5 44f68ce5b9d3a97687ea29b27b4bce85
BLAKE2b-256 3ba215765c9547051ed694d36187a0ba276bf429b1929c6b53cd953e3769fbb8

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