If part 5 put stop conditions on the loop, the next question is: who speaks next, what can run in parallel, and which node catches failure? When a single plan→act→observe line can’t draw the workflow anymore, you need a map.
Takeaway: Graph engineering is not making the model smarter. It is making nodes (roles/stages), edges (deps/routing), and state (shared contracts) explicit so “who does what when” is no longer vibes.
This is part 6 of Coding Is Conversation, after loops. Multi-agent roles and harness walls are assumed.
When a loop isn’t enough
| Symptom | Loop-only | Graph helps when |
|---|---|---|
| Roles change | One agent does all | Ownership moves Research → Implement → Review |
| Work splits | Stuffed into a sequence | Research A/B in parallel, then merge |
| Policy splits | Giant prompt if/else | Conditional edges route |
| Failure handling | Same-turn retry | Escalation node (human / senior role) |
A loop (part 5) is the rhythm inside a node. A graph is the transit map between nodes. WIP=1 still applies—don’t “consume” the whole graph at once; run only the active node(s).
Rendering diagram…
Implement→Gate→Review is mostly a pipeline (DAG-ish). Review↔FactFix is a quality cycle. Don’t mash both into one vague word.
DAG vs cycle — name them precisely
- DAG (Directed Acyclic Graph): directed edges, no cycles. Fits editorial stage pipelines, build deps, “Outline waits on Research.”
- Graph with cycles: agent feedback, retries, review loops. LangGraph models these with nodes, edges, and shared
State, executing in super-steps (Graph API, as of 2026-08-03). - Working rule: outer DAG (stages/gates), inner loops (part 5
max_turns). Cycles on the outer topology make debugging miserable.
PapaCoder’s Workflow Engine card runs pipelines as an agent DAG with dependencies (agents/platform-intelligence/workflow-engine.md). Orchestration code stays deterministic; LLMs stay probabilistic inside nodes.
Nodes, edges, state
| Piece | Meaning | Practice |
|---|---|---|
| Node | One responsibility | Research, KR Writer, Fact Checker, Human Approve |
| Edge | Where next | Outline → KR Writer, accuracyFail → revise |
| Conditional edge | Branch on Observe | tests fail → Implement, pass → Review |
| State | Shared contract nodes read/write | brief JSON, draft markdown, quality scores |
Loose state schemas turn graphs into “several chats.” Part 3’s typed handoffs climb into this layer.
Handoffs vs agents-as-tools
OpenAI’s orchestration guide splits two patterns (Orchestration, as of 2026-08-03):
| Pattern | When | What happens |
|---|---|---|
| Handoffs | A specialist should own that branch’s reply | Control moves to the specialist |
| Agents as tools | The manager should keep the final answer | Manager calls specialists as bounded tools |
In the SDK, a handoff is delegation to another agent (Handoffs)—graph-speak: ownership transfer on an edge. Don’t split every sentence into a handoff; add nodes only when instructions, tools, or policy actually change—the guide says the same.
I used to dump “research, implement, and review” into one Agent session. Quality flickered. Pinning Research / Implement / Review as nodes and changing only conditional edges made failures visible.
When to add a human escalation node
Criteria (ties to parts 4–5):
- Judgment the harness can’t encode — product priority, legal/brand, “ship this draft?”
- Loop budget exhausted —
max_turns/ same failure ×N / wall clock - Policy gate failure — accuracyFail, secret boundary, production deploy
- Parallel merge conflict — two Research briefs contradict and auto-merge is unsafe
Escalation is not shame; it’s a designed edge. Don’t leave “a human will look later” implicit—name the node and its entry conditions.
Practice: a weekend graph sketch
Lock a text DAG before picking a framework:
# draft-pipeline.graph
nodes:
eic: { wip: 1, artifacts: [EditorialBrief] }
research: { depends: [eic], artifacts: [ResearchBrief] }
outline: { depends: [research], artifacts: [Outline] }
write_ko: { depends: [outline], artifacts: [draft.ko] }
write_en: { depends: [outline], artifacts: [draft.en] } # parallel OK after outline
review: { depends: [write_ko, write_en], gate: score>=85 }
facts: { depends: [review], gate: accuracyPass }
publish: { depends: [facts], owner: human } # never auto
edges_conditional:
review.on_fail -> write_ko # revise with new Observe
facts.on_fail -> review
any.max_turns -> human
In LangGraph, add nodes on a StateGraph, wire add_conditional_edges, then compile(). If cycles exist, keep part 5’s recursion_limit as the outer budget.
With the OpenAI SDK, triage→specialist reads cleanly as handoff edges; a summarizer helper often fits better as as tool.
Cursor notes
- Fan out Research with Task/subagents; merge only in the parent chat—the parent is the WIP=1 orchestrator.
- Don’t ask one thread to “investigate, implement, and review.” Split by node (thread or staged prompts).
- Persist each node’s artifact to a file (
research-brief.md, …)—that’s your shared State. - A graph without stop rules / hooks / CI (part 4) is a pretty picture.
PapaCoder’s editorial DAG
agents/editorial/workflow.md is already a graph:
EiC → Research → Outline → KR Writer → EN Writer
→ Humanizer → Reviewer → Fact Checker → SEO → Publisher(draft)
↘ accuracy/score fail → revise (new input)
Publisher → Admin(human publish)
The series orchestrator (series-draft-run.md) runs this DAG for one slug (WIP=1). Part 7 field notes show how the same map lands on real repos.
FAQ
Q. Multi-agent (part 3) vs graph?
A. Part 3 is roles and contracts. Part 6 is how those roles connect over time (topology). A graph of empty boxes helps nobody.
Q. Must every workflow be LangGraph?
A. No. Straight lines are fine as loop + checklist. Pay for a graph when branching, parallelism, and gates dominate.
Q. Is a review loop allowed in a “DAG”?
A. Keep outer stage deps acyclic; isolate quality retries as a subgraph / inner loop.
Q. Can auto-retry replace escalation?
A. Only inside budget. Past budget, the human node is correct (part 5).
Sources
- LangGraph — Graph API — https://docs.langchain.com/oss/python/langgraph/graph-api (as of 2026-08-03)
- OpenAI — Orchestration and handoffs — https://developers.openai.com/api/docs/guides/agents/orchestration (as of 2026-08-03)
- OpenAI Agents SDK — Handoffs — https://openai.github.io/openai-agents-python/handoffs/ (as of 2026-08-03)
- PapaCoder —
agents/editorial/workflow.md,agents/platform-intelligence/workflow-engine.md
What’s next in the series
| # | Topic |
|---|---|
| 01–05 | Tools → vibe → multi-agent → harness → loops |
| 06 | Graphs (this post) |
| 07 | PapaCoder field notes — same patterns on real product/repos |
Next: field notes—theory off the desk.
One line to keep: When a line isn’t enough, draw the map—outer DAG, inner loops, human node when stuck.