Skip to lesson
supraj.dev THE ENGINEERING HANDBOOKS
LEARN / BUILD / VERIFY2026 edition · checked 06 Oct

CHAPTER 21 / 30 · Connect and coordinate

Use graphs when order is part of correctness

Make dependencies explicit and test branching, joins and failure propagation.

4 min read + practiceWorked exerciseInterview practice

The mechanism

A graph describes nodes and dependencies. It is appropriate when the workflow has an order that matters: gather evidence, analyze it, then produce a report. A model can still reason inside a node, while the application controls which nodes may run and how results move between them. This separates flexible reasoning from deterministic workflow structure.

ParcelOps uses a simple chain before attempting parallel branches. The evidence node reads a synthetic incident; the report node summarizes only that evidence. A sequential graph is easier to inspect than a complex network of conditional edges, and it establishes the result contract needed for later branching.

Evidence node
Verified result contract
Report node
Application acceptance checks

A worked graph

Configuration only; calling the graph can invoke multiple model turns. The model and lookup tool are the earlier approved examples.

from strands import Agent
from strands.multiagent import GraphBuilder

reader = Agent(model=model, name="reader", tools=[lookup_incident],
               system_prompt="Read the requested synthetic incident; preserve evidence IDs.",
               callback_handler=None)
writer = Agent(model=model, name="writer", tools=[],
               system_prompt="Summarize supplied evidence and explicitly state uncertainty.",
               callback_handler=None)

builder = GraphBuilder()
builder.add_node(reader, "read")
builder.add_node(writer, "report")
builder.add_edge("read", "report")
builder.set_entry_point("read")
graph = builder.build()
# Optional inference: result = graph("Explain INC-104 without changing it.")

Do not assume that a diamond graph has identical join behavior across SDKs. Current official documentation describes Python conditional dependency resolution with OR semantics and TypeScript with AND semantics. If a report must wait for two independent checks, verify that requirement with a trace-based test in the pinned implementation rather than relying on the diagram’s appearance.

The graph’s node order does not prove the content is correct. The report node can still invent a fact, omit uncertainty or misread an upstream result. Keep schema and evidence verification outside the probabilistic node, and distinguish a node that completed from a business task that passed acceptance.

Practice: build a dependency truth table

Offline. Draw a diamond with “read incident” feeding “check timeline” and “check runbook,” both feeding “report.” List all combinations of branch success, failure and missing output. For each, decide whether the report may run and what it should disclose.

Expected observation: dependency completion, dependency success and sufficient evidence are different conditions. A failed branch may still be complete from the scheduler’s perspective. Your application must define whether a partial report is acceptable and how it labels the missing check.

Then design a graph test with controlled nodes that record execution order. These test doubles should return fixed values and make no model calls. Verify the intended join semantics before replacing them with real agents. Include a cycle only when it has an explicit exit condition and execution limit.

Troubleshooting and trade-offs

A node running too early may reflect join semantics, a conditional edge or an incorrectly declared dependency. Inspect recorded transitions instead of adding sleeps. A cycle that never terminates needs a bounded policy and a meaningful completion condition; prompting an agent to “stop eventually” is not enough.

Graphs add structure but also state and recovery complexity. For two deterministic operations, ordinary application code may be clearer. Choose a graph when its explicit orchestration and observability help the system, not because every agent application needs a multi-agent diagram.

Interview practice

Why test a graph with deterministic nodes first?

It isolates scheduling, dependency and failure semantics from model variation. You can prove which nodes ran and in what order before evaluating reasoning quality.

What can go wrong when porting a diamond graph between SDKs?

Join and conditional dependency semantics may differ. A downstream node may run after one branch in one implementation but wait for all branches in another. Verify the pinned behavior and acceptance conditions.

Completion check

Produce a dependency truth table and a controlled execution trace. Explain how the report handles a failed branch. State the Python/TypeScript join difference without claiming untested cross-language parity.

Sources and version notes

Checked 6 October 2026. Python examples target strands-agents==1.58.0 unless labelled otherwise. Live documentation can change; compare your installed version before adapting an example.

YOUR NEXT STEP

Make the understanding yours.

Use the completion check above. Mark this chapter when you can explain the mechanism and its limits.

Self-assessed reading progress. This does not certify that a lab ran or a system is secure.