langchain-dynamic-workflow / examples
AGENTS.md18 starsChanged 6 months agoMITView on GitHub
This file is the authoritative guide for the example set: what lives here, how the demos are organized, and how to add or change one without drifting. The root README.md points here for the full demo index; keep this file in sync when you add, rename, or remove a demo. examples/ is a copy-paste-ready set of host-wiring integration examples and the outward proof of the engine's capabilities. Each file shows a real host driving the workflow runtime end to end…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- examples/CLAUDE.mdCLAUDE.md
- github-prSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 65
Read in this order to build up from a single leaf to the full flagships:
- Very specific: line 85
Put it in features/<name>.py with a descriptive, unnumbered name.
- Distinctive: line 105
When a new gap is closed, run its real-model end-to-end acceptance as a
- Distinctive: line 115
Every feature demo follows the same shape:
- Distinctive: line 149
README sync: When you add, rename, or remove a demo, update the table in §2 of this file and the Examples pointer in the root README.md.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Guidance for examples/
This file is the authoritative guide for the example set: what lives here, how the
demos are organized, and how to add or change one without drifting. The root
README.md points here for the full demo index; keep this file in sync when you
add, rename, or remove a demo.
1. Purpose
examples/ is a copy-paste-ready set of host-wiring integration examples and the
outward proof of the engine's capabilities. Each file shows a real host driving the
workflow runtime end to end — not a unit test and not a tutorial that narrates tool
mechanics. Read a demo to see exactly how a deployment would wire one capability into
a host, then lift the wiring into your own code.
2. Two-layer taxonomy
The set has exactly two layers, with different rules:
- Flagships (
flagship/, 2 demos): the only real-model demos and the only ones that combine multiple mechanisms. They run a full deep-research pipeline (parallel search → extract → adversarial verify → synthesize) on live models with native web search and prompt caching. A flagship is expensive to maintain and is not added casually — the bar is a genuinely new end-to-end story, not a new single feature. - Feature demos (
features/, 19 demos): each demonstrates exactly one mechanism, runs fully offline and deterministically, and needs no API key. They use the shared scripted fakes in_shared/offline_models.py, so they are fast, reproducible, and safe to run in CI.
Authoritative demo index
This table is the authoritative index of every demo. The two flagships:
| Demo | Mechanism |
flagship/deep_research_preset | Real-model host drives the registered deep_research workflow: parallel search → extract → adversarial verify → synthesize, with native web search + prompt caching; schema-as-handoff and reduce are embedded in the registered workflow. |
flagship/deep_research_authored | Real-model host authors the deep-research script live and submits it via run_script (AST-gate happy path), then runs it on the same web-search + caching leaf stack. |
The 19 feature demos, one mechanism each:
| Demo | Single mechanism |
features/agent_and_schema | agent() single-leaf end to end + structured-output schema handoff. |
features/parallel | parallel() barrier fan-out + filtering failed leaves (cross-reference pipeline). |
features/pipeline | pipeline() no-barrier staged flow (cross-reference parallel). |
features/race | ctx.race best-of-N early exit + in-flight cancel + journaled determinism (replay reproduces the winner and dispatches nothing new). |
features/nesting | workflow() named nesting — multiple levels deep + cycle guard. |
features/dag | ctx.dag dependency-order (topological) fan-out + transitive skip of a failed branch. |
features/budget | loop-until-budget / loop-until-dry via ctx.budget.remaining(). |
features/observability | phase() / log() narration + the full tap set — on_progress / on_span for the trace, on_span_begin for the running edge, on_leaf_event for a leaf's run-tree subtree (the same surfaces the demo app consumes). |
features/reduce | cross-leaf reduce family: gather → dedup → corroborate → survives (voting) → reconcile (double-blind reconciliation). |
features/journal_resume | in-process resume: content-hash journal replay + fail-loud determinism guard. |
features/persistence | cross-session sqlite store: proc1 launches → "restart" → proc2 resumes, zero-cost replay (an offline counter proves the replay is free). |
features/sandbox | per-leaf sandbox isolation + /shared/ artifact handoff. |
features/worktree | worktree-isolated fix swarm (parallel fixers cannot see each other's edits). |
features/git_worktree | real-git worktree fix swarm: per-leaf git worktree isolation, the engine folds the real git diff as the authoritative changeset, a script-owned git merge conflict loop resolves an overlap, and the host opens a PR (zero API key; needs git on PATH). |
features/readonly_judge | read_only_leaf: a judge is denied at the tool boundary even when asked to write. |
features/ast_gate | meta-layer safety seam: an unsafe script → precise AST-gate rejection → rewrite → run. |
features/host_integration | create_workflow_tool / create_workflow_middleware wired into a scripted host; the host launches N background runs and views the aggregate runs board. |
features/signoff | in-run HITL sign-off: ctx.checkpoint parks the run for a human, the host catches WorkflowSignoffRequired and resumes with the decision (pre-gate leaf replays for free; approve proceeds, reject holds). |
features/bug_vuln_sweep | ctx.batch_map bounded streaming fan-out over a large file list + live count/ETA BATCH progress, results folded with dedup. |
Suggested learning path
Read in this order to build up from a single leaf to the full flagships:
agent_and_schema— one leaf, structured handoff.parallel→pipeline→dag→bug_vuln_sweep— fan-out with a barrier, a staged flow without one, dependency-order (topological) fan-out with transitive skip, andbatch_mapbounded streaming fan-out over a large list with a live count/ETA bar.budget→observability→journal_resume— loop control, narration, replay.reduce— synthesizing many leaf results into one.race— best-of-N early exit and journaled cancel.nesting— composing named sub-workflows multiple levels deep, with a cycle guard.host_integration— wiring the runtime into a host and watching many runs.sandbox→worktree→git_worktree→readonly_judge— isolation (in-memory then real-git, with an authoritative diff + script-owned merge) and tool-boundary guards.ast_gate— the meta-layer reject-and-retry seam.flagship/deep_research_preset→flagship/deep_research_authored— the full real-model combination, registered vs. authored live.
3. How to add a demo
A new core feature gets one offline feature demo:
- Put it in
features/<name>.pywith a descriptive, unnumbered name. - Build its host and leaves from
examples._shared.offline_modelsso it runs with zero API key, deterministically, viauv run python -m examples.features.<name>. - End the demo with an assertion that proves the mechanism — that assertion doubles as the per-demo smoke check.
Respect the 道 / 术 line from the root AGENTS.md. A host's system_prompt
carries only the mental model (the why and when): control-flow inversion,
decomposing a hard task into parallel sub-work and synthesizing, cross-checking before
committing, delegating heavy multi-step work to the background, composing a procedure
when no ready-made one exists. The prompt must not teach mechanics: no command
names (run / run_script / status / resume / cancel), no registered-workflow
names, no args shapes, no script-authoring steps, no AST-gate rules. User messages
read like a real user's words — a natural request, never tool instructions.
Feature demos must not carry an LDW_DEMO_REAL_MODEL real path. The real path
belongs to the flagships only.
4. Per-gap real-model acceptance
When a new gap is closed, run its real-model end-to-end acceptance as a development-time gate — a temporary real run, or by extending a flagship to exercise the new path — not as a resident real path inside a feature demo. The two flagships carry the permanent real-model coverage; CI stays offline. If a real-model host cannot complete a flagship from a 道-level prompt plus the skill plus the tool description alone, that is a signal to improve the skill or the tool description, never to drop 术 into the prompt.
5. Demo skeleton convention
Every feature demo follows the same shape:
- A module docstring naming the single mechanism the demo proves.
- An
async def main()entry point. - Print the results so a reader sees what happened.
- Assert the mechanism — this doubles as the smoke check.
- A trailing comment with the
-mrun command.
Offline-scripted hosts encode their turn logic in code, not in a prompt, so they are exempt from the prompt persona rule of §3 — but their user messages still read naturally, like a real person's request.
6. Scaffolding, naming, and README sync
Shared scaffolding lives in _shared/:
_shared/offline_models.py— reusable deterministic fakes for feature demos (ScriptedModel,echo_leaf,structured_leaf,structured_builder,ToolCallThenReplyModel). Prefer reusing these over inlining a new fake._shared/real_models.py—ChatOpenRouter+ provider lock + native web search +load_demo_env/real_model/real_leaf_model/demo_cache_middleware. Flagship-only._shared/prompt_caching.py—PromptCachingMiddleware. Flagship-only (it is a no-op offline, so feature demos do not need it).
Naming and placement. Names are descriptive and unnumbered. Flagships go in
flagship/, feature demos in features/. Reading order is given by the learning path
in §2, so inserting a new demo never forces a renumbering.
Packaging. examples/ and its subpackages carry __init__.py so demos run as
modules (uv run python -m examples.features.<name>); the repo root is on sys.path
and demos use absolute imports (from examples._shared.offline_models import ...).
examples/ is not shipped in the wheel — the package exists only for -m imports.
README sync. When you add, rename, or remove a demo, update the table in §2 of this
file and the Examples pointer in the root README.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

