Repository navigation
V1 Workflows en
简体中文 | English
Applies to v1.0.0. Do not introduce durable scheduling for a simple role handoff, or treat unconstrained handoffs as a verified workflow.
| Need | Entry point | Completion condition |
|---|---|---|
| Route a conversation to an Agent with another role | LightSwarm |
The target Agent replies. Hooks and policies control handoff. |
| Run known steps with known dependencies | LightFlow |
Dependencies, checkpoints, approvals, and per-step state can be inspected. |
| Add tasks during execution and verify artifacts | LightDAG |
Only an application-owned Verifier can accept and publish candidate artifacts. |
| Reconnect to a single long-running task that need not be a DAG | ExecutionService |
The backend confirms that execution ended; the application validates the result separately. See Durable Tasks. |
The steps below use local Python objects. Replace them with configured LightAgent instances in a real application.
from tempfile import TemporaryDirectory
from LightAgent import ApprovalDecision, JsonLightFlowStore, LightFlow
class LocalWriter:
def run(self, query, **kwargs):
return "草稿:" + query
with TemporaryDirectory() as directory:
def create_flow():
return (
LightFlow(store=JsonLightFlowStore(directory))
.step("draft", agent=LocalWriter())
.step("review", agent=LocalWriter(), depends_on=["draft"], requires_approval=True)
)
flow = create_flow()
waiting = flow.run("描述验收计划", run_id="report-001")
assert any(step.approval_request_id for step in waiting.steps)
reconnected = create_flow()
reconnected.approve("report-001", "review", ApprovalDecision.approve(reviewer_id="editor"))
done = reconnected.resume("report-001")
assert done.success
print([(step.name, step.status) for step in done.steps])Use depends_on to declare upstream steps and a step's query callback to build bounded downstream inputs. Retrying cannot repair a cycle or unknown dependency. LightFlow supports per-step retry, timeout, fallback, conditional skip, cancellation, tracing, and persisted checkpoints. Inspect runs with get_run() and list_runs(). rerun_step(run_id, step_name) reruns that step and its dependents. Reusing an explicit completed run ID returns the stored checkpoint without invoking Agents again. Approval can allow, reject, edit, or supply a result. Authenticate reviewers and prevent cross-run reuse. The JSON store is for lightweight local use, not distributed queuing. See the LightFlow Reference for arguments and statuses.
Using the model configuration in Getting Started, create a front-desk Agent and a support Agent. The example assumes frontdesk and support have distinct name, role, and instructions settings and serve the same request tenant:
from LightAgent import LightSwarm
swarm = LightSwarm()
swarm.register_agent(frontdesk, support)
print(swarm.run(agent=frontdesk, query="如何导出应用的运行日志?", stream=False))The model selects the intended role; it need not make the same choice every time. Use on_handoff to review handoffs, restrict targets, and preserve the parent trace. Delegation must not override permission or memory boundaries. The complete multi-agent example and the failure map cover registration, role descriptions, and transport behavior. Use LightFlow rather than free handoff when execution order must be fixed.
From a v1.0.0 checkout, run this complete offline example. It splits a root task into two children, repairs a task after a failed verification, and integrates the verified artifacts:
python example/14.dynamic_dag.pyTo integrate it in an application:
- Construct
LightDAGwith an explicitSqliteTaskGraphStore,LocalArtifactStore, resource limits, and a trustedCallableVerifier. - Register a Worker. Return
TaskOutcome.candidate(),decompose(), orblocked(), not an arbitrary string as proof of completion. - In
TaskSpec, define the goal, acceptance contract, Worker, and Verifier. Pass tenant, project, and permissions from a trustedSecurityContexttocreate_run(). - A decomposition proposal carries a graph revision. The runtime checks dependencies, cycles, quotas, leases, and the revision before updating the graph. The parent integrates only after its dependencies publish verified artifacts.
- Use
list_tasks()to inspect state. Only an authorized host should pause, cancel, resume, clear a blocker, or replace an unfinished task. Verified artifacts are read by digest and published status. Create a new run to change an already-verified contract.
See the LightDAG Reference for another model-free example and runtime details. Workers can call explicit backends, but the Verifier must check the domain requirements independently of the model's success claim. Scheduling is single-host; leases and fencing reject stale results, but cannot undo external side effects.
LightAgent Wiki - see the repository, releases, and issues.
- Installation and Your First Agent
- Tools and Integrations
- Memory, Sessions, and RAG
- Workflows and Multiple Agents
- Agent Backends and Codex
- Durable Execution, Jobs, and Subagents
- Safety, Observability, and Evaluation
- Usage, Cost Estimates, and Budgets
- Deployment, Migration, and Verification
- 安装与第一个 Agent
- 工具和集成
- 记忆、会话与 RAG
- 工作流与多 Agent
- 执行后端与 Codex
- 持久执行、Jobs 与 Subagents
- 安全、观测与评测
- 用量统计、费用估算与预算
- 部署、升级与验收
- Quick Start
- Core Concepts
- API Reference
- Examples Cookbook
- Migration Guide
- Tools
- Tool Generator
- Memory
- MCP
- Skills
- LightFlow
- Tree of Thought
- Self-Learning
- Multi-Agent
- Tracing and Debugging
- Langfuse Observability
- Model Providers
- browser-use Integration
- Testing and CI
- Deployment Guide
- Architecture
- Security
- Known Limitations
- FAQ
- FAQ 中文
- Roadmap
- Release Process
- Contributing