Skip to content

Locale en · ko

Draw the Map When a Line Isn’t Enough — Graph Engineering

By Harin Kim · Published 4 Aug 2026 · Updated 3 Aug 2026

Summary

Part 6 of Coding Is Conversation. DAGs, conditional edges, handoffs vs agents-as-tools, and human escalation nodes.

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

SymptomLoop-onlyGraph helps when
Roles changeOne agent does allOwnership moves Research → Implement → Review
Work splitsStuffed into a sequenceResearch A/B in parallel, then merge
Policy splitsGiant prompt if/elseConditional edges route
Failure handlingSame-turn retryEscalation 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

PieceMeaningPractice
NodeOne responsibilityResearch, KR Writer, Fact Checker, Human Approve
EdgeWhere nextOutline → KR Writer, accuracyFail → revise
Conditional edgeBranch on Observetests fail → Implement, pass → Review
StateShared contract nodes read/writebrief 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):

PatternWhenWhat happens
HandoffsA specialist should own that branch’s replyControl moves to the specialist
Agents as toolsThe manager should keep the final answerManager 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):

  1. Judgment the harness can’t encode — product priority, legal/brand, “ship this draft?”
  2. Loop budget exhaustedmax_turns / same failure ×N / wall clock
  3. Policy gate failure — accuracyFail, secret boundary, production deploy
  4. 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

What’s next in the series

#Topic
01–05Tools → vibe → multi-agent → harness → loops
06Graphs (this post)
07PapaCoder 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.

Related posts

More in Tutorials

Comments

Checking sign-in…

No comments yet.