Human-reviewed Agent DAG framework
Project description
Plan globally. Re-plan locally.
Documentation | 中文文档 | PyPI | License
dagent is a Dynamic DAG Agent framework. It can automatically route a
request, run it through a bounded tool-using agent, or use a planner that creates
and executes a reviewable capability-node DAG. Public agent objects are
declarative configuration, while Runner owns the runtime session, capability
catalog, review continuations, and execution state.
Traditional agent frameworks choose one of two extremes: a free-running ReAct loop with no structure, or a rigid static pipeline with no adaptability. dagent rejects both. Work that needs orchestration gets a reviewable, auditable plan up front. That plan can evolve from DAG observations as execution proceeds, while completed tool results remain structured execution records.
Design origin: The self-planning dynamic DAG agent loop - capability-node DAG with three-level incremental re-planning, Trace DB as the long-term context boundary, human review checkpoints, DAG-vs-tool task routing, and resumable execution - was conceived and first implemented by the author of this repository. First committed: 2026-05-01.
Core Ideas
1. Reviewable plans, not opaque loops. Tasks that need orchestration become capability-node DAGs before execution. The plan is typed, inspectable, and can pause for human review before risky work runs.
2. Typed nodes with direct capability calls.
Every DAG node has a typed payload. Capability nodes wrap a
CapabilityInvocation; start nodes are explicit and do not carry fake tool
calls. The runtime executes capabilities through a shared CapabilityExecutor.
3. Structured parameter passing between nodes.
Static DAG arguments can reference graph input, upstream node results, and
artifact paths. These references are structured $expr bindings in DAGSpec,
resolved immediately before a capability call. A node that reads another node's
output must explicitly depend on it.
4. Re-planning stays local.
After each executable DAG layer, the planner receives a DAG observation and can
return NO_CHANGE, a revised PlanSpec, or a final answer. Completed node
results stay as structured execution records instead of being rediscovered from
chat history.
5. Runner owns runtime state.
Public AutoAgent, ToolAgent, DagAgent, and Dag objects are declarative
configuration. Runner owns the provider, capability catalog, session state,
review continuations, and execution dispatch.
6. Safety is part of execution, not prompting. The DAG planner proposes work, but capability handlers enforce boundaries before side effects. Medium/high-risk work can require review; disabled or unknown capabilities fail closed; file boundaries reject path escape.
Quick Start
Install the PyPI package as dagent-ai; import it in Python as dagent:
pip install dagent-ai
Register a Python tool, configure an OpenAI-compatible provider, and run a
bounded ToolAgent:
import asyncio
import dagent
@dagent.tool
def echo(text: str) -> str:
return f"echo:{text}"
async def main():
provider = dagent.Provider(
base_url="https://api.openai.com/v1",
model="your-model",
api_key_env="OPENAI_API_KEY",
)
runner = dagent.Runner(workspace=".dagent", provider=provider, capabilities=[echo])
agent = dagent.ToolAgent(profile="conversation", capabilities=["tool.echo"])
result = await runner.run(
agent,
messages=[{"role": "user", "content": "Use echo to respond with hello."}],
)
print(result.output_text)
runner.close()
asyncio.run(main())
For a complete first run, static DAG example, provider configuration, and local development setup, read the Quick Start.
Run offline examples from the repository root:
uv run python -m examples.tool_agent
uv run python -m examples.static_dag
uv run python -m examples.streaming
Architecture
flowchart TD
U["User / SDK"] --> RUN["Runner"]
RUN --> HR["HarnessRuntime"]
HR -->|"AutoAgent routes to tool"| TA["ToolAgent"]
HR -->|"ToolAgent target"| TA
HR -->|"AutoAgent routes to DAG"| DA["DAGAgent"]
HR -->|"DagAgent target"| DA
HR -->|"Dag / DAGSpec target"| DS["DAGSpec"]
TA --> TAL["ToolAgentLoop"]
TAL -->|"capability call"| CE["CapabilityExecutor"]
DA --> DAL["DAGAgentLoop"]
DAL -->|"PlanSpec DSL"| DAG["DAG"]
DS -->|"compile"| DAG
DAG --> RG["Review Gate"]
RG --> DE["DAGExecutor"]
DE -->|"ready layer"| CE
CE --> CAT["Capability Catalog"]
CE --> RT["RunTrace + Artifacts"]
RT --> OBS["DAG Observation"]
OBS --> DAL
HR --> RR["RunResult"]
Runner is the public SDK entrypoint and owns the configured runtime, session,
and capability catalog. HarnessRuntime is the lower-level control layer for
routing, review continuations, optional result validation, and final response
delivery.
AutoAgent lets the runtime route each request to direct tool use or dynamic
DAG planning. ToolAgent delegates bounded tool-loop work to ToolAgentLoop.
DagAgent delegates dynamic planning and fixed DAGSpec execution to
DAGAgentLoop. Both paths share CapabilityExecutor, so Python tools, MCP
tools, skill accessors, shell commands, file tools, memory, and agent
capabilities go through the same catalog and boundary enforcement.
DAGExecutor validates graph structure, resolves structured value expressions,
executes ready layers, updates artifact state, and returns a cumulative
RunTrace.
Project Layout
api/ local FastAPI backend for the WebUI
dagent/
capabilities/ capability catalog, providers, adapters, and built-in handlers
harness_runtime/ runtime orchestration, agent loops, validation, session state,
event adapters, DAG execution
providers/ OpenAI-compatible and mock chat providers
resources/ packaged default Markdown profiles
schemas/ DAG, node, edge, trace, feedback, result/outcome contracts
state/ prompt assembly
docs/ user-facing documentation
examples/ runnable SDK examples
web/ React + Vite frontend
tests/ pytest suite
Key runtime contracts such as RunState, RunTrace, LoopOutcome,
PendingReview, and validation result types live in dagent/schemas.
harness_runtime owns behavior; schemas owns shared data contracts.
Documentation
License
Apache License 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dagent_ai-0.6.1.tar.gz.
File metadata
- Download URL: dagent_ai-0.6.1.tar.gz
- Upload date:
- Size: 224.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53115751e29b04ef6595eca0e43e38edfe7398f0bebce04185e25ab34af9963
|
|
| MD5 |
d8c4cd03a0d6c1f4596bb63f8a131e3c
|
|
| BLAKE2b-256 |
25d6b7938627bc73c1d2ee90b9eb25a638cdde1ece0ba5259509606cfb91ce5c
|
Provenance
The following attestation bundles were made for dagent_ai-0.6.1.tar.gz:
Publisher:
publish.yml on RobotSe7en/dagent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagent_ai-0.6.1.tar.gz -
Subject digest:
d53115751e29b04ef6595eca0e43e38edfe7398f0bebce04185e25ab34af9963 - Sigstore transparency entry: 2002472446
- Sigstore integration time:
-
Permalink:
RobotSe7en/dagent@a435f45a85718e1a4ab1d62c421b6606709b8606 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/RobotSe7en
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a435f45a85718e1a4ab1d62c421b6606709b8606 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dagent_ai-0.6.1-py3-none-any.whl.
File metadata
- Download URL: dagent_ai-0.6.1-py3-none-any.whl
- Upload date:
- Size: 147.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a852b25c0cbdd0fbdcdd4a57f0fb832527f1f4b4c432befdd20d6c5a8cb9044
|
|
| MD5 |
95a51f5356f9912f05896913f1f703ad
|
|
| BLAKE2b-256 |
e6b422e3e5b62ffadc494ce653b8b226b841f994eba7f34a95a901663e4a0d4d
|
Provenance
The following attestation bundles were made for dagent_ai-0.6.1-py3-none-any.whl:
Publisher:
publish.yml on RobotSe7en/dagent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagent_ai-0.6.1-py3-none-any.whl -
Subject digest:
8a852b25c0cbdd0fbdcdd4a57f0fb832527f1f4b4c432befdd20d6c5a8cb9044 - Sigstore transparency entry: 2002472551
- Sigstore integration time:
-
Permalink:
RobotSe7en/dagent@a435f45a85718e1a4ab1d62c421b6606709b8606 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/RobotSe7en
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a435f45a85718e1a4ab1d62c421b6606709b8606 -
Trigger Event:
release
-
Statement type: