1 · The seven layers concept
Read from the bottom up. Each layer is chosen separately — but only two edges between them are real constraints.
2 · Only two edges are real constraints key insight
Constraint A — the wire format pins the client
There are effectively two formats in the world:
- OpenAI Chat Completions — the de-facto standard. Azure OpenAI, most gateways, most open models, most self-hosted servers.
- Anthropic Messages — Anthropic API; also available on Bedrock and Vertex.
Your gateway speaks one of them, and that decides your client SDK. It is not a judgement call.
Constraint B — orchestration decides lock-in
The rule that resolves almost every "am I locked in?" question:
Frameworks that own the loop are tied to a model family.
Frameworks that own the graph are model-agnostic.
Plain code is always agnostic.
An agent framework decides what to call next, so it is built around one model's tool-calling and stop semantics. A graph framework only decides what runs after what and takes whatever client you hand it.
3 · Layer 3 in depth — who owns the loop? the confusing one
The four options differ on exactly one question: who owns the while loop?
1 · Plain code — you own the loop
def heal(failure): cause = analyse(failure, graph) # your function text = llm.complete(system, prompt) # ← client SDK, one call fix = generate(cause) # your function if gate(fix).approved: deploy(fix)
Nothing hidden, every branch written by you. Debuggable with a breakpoint.
2 · Agent framework — the model owns the loop
agent = Agent(model="claude-sonnet-5", tools=[read_logs, query_graph, run_sandbox]) result = agent.run("Diagnose why curate_orders failed") # the model decides the sequence at runtime: # read_logs → query_graph → read_logs again → conclude
Inversion of control. You supply tools; it supplies the plan. You cannot know the sequence in advance — which is the point, and the cost.
3 · Graph framework — you declare the loop, it runs it
g = StateGraph(Case) g.add_node("rca", rca_fn) g.add_node("deploy", deploy_fn) g.add_conditional_edges("gate", route, {"auto": "deploy", "human": END}) app = g.compile(checkpointer=SqliteSaver("cases.db"))
You still decide the sequence — but declared rather than written, and you get checkpointing, resume and a picture of the topology in return.
4 · Durable execution — looks like plain code, survives death
@workflow.defn class HealWorkflow: @workflow.run async def run(self, failure): cause = await workflow.execute_activity(analyse, failure) await workflow.wait_condition(lambda: self.approved) # can wait DAYS await workflow.execute_activity(deploy, fix)
That wait_condition spans a process restart, a deployment, a weekend. The runtime
persists every step.
| Option | Owns the loop | You get | You pay | Model-agnostic? |
|---|---|---|---|---|
| Plain code | You | Full control, trivial debugging, no dependency | You build resume and retries yourself | ✅ always |
| Agent framework | The model | Handles paths you cannot enumerate | Non-determinism, cost, harder debugging, lock-in | ❌ per model family |
| Graph framework | The framework | Checkpointing, resume, branch/parallel, visualisation | A DSL to learn; indirection | ✅ you supply the client |
| Durable execution | The runtime | Survives crashes and long waits; retries and timers | A server to operate; a programming model | ✅ you supply the client |
Choosing, in order
- Can you write the steps down? → plain code. Stop here far more often than feels natural.
- Must a run survive a crash or a long human wait? → durable execution.
- Is the topology genuinely complex — branches, parallel, joins? → graph framework.
- Does the model need to choose the sequence because you cannot know it? → agent framework.
4 · Compatibility — orchestration × provider matrix
| Layer-3 choice | Owns | Works with | Through Kong → Azure OpenAI? |
|---|---|---|---|
| Plain code + a model client | nothing | Every provider, every model | ✅ yes |
| LangGraph, LlamaIndex Workflows, Burr | the graph | Every provider — you supply the client | ✅ yes |
| Temporal, Restate, Step Functions | durability | Everything; wraps any of the above | ✅ yes |
| OpenAI Agents SDK | the loop | OpenAI, Azure OpenAI, OpenAI-compatible endpoints | ✅ yes |
| MS Agent Framework / Semantic Kernel | the loop | Azure OpenAI first; others via connectors | ✅ yes |
| Claude Agent SDK | the loop | Claude models only — Anthropic API, Bedrock, Vertex | ❌ no |
| Strands (AWS) | the loop | Bedrock first | ⚠️ not the usual path |
| Google ADK | the loop | Vertex first | ⚠️ not the usual path |
5 · Why the permutation count is a red herring
Multiplied out, the stack looks terrifying:
But the layers cascade rather than combine. In practice you take four decisions, in this order, and each one collapses the space:
| # | Decision | Who really makes it | What it collapses |
|---|---|---|---|
| 1 | Provider + gateway | Your organisation, usually before you arrive | Layers 5 and 6 — down to one |
| 2 | Wire format | Nobody — it falls out of #1 | Layer 4 — down to one |
| 3 | Orchestration | You. The only free architectural choice | Decides whether layer 7 stays free |
| 4 | Model | You — measured, not asserted | A config value if #3 was chosen well |
Language and runtime are orthogonal to all four. So the real decision tree is four nodes deep, not seven — and only one node is genuinely yours.
6 · A worked example applied
The same system, running in a corporate estate and on a personal free-tier account. One code path.
| Layer | Enterprise | Demo / laptop | Changed? |
|---|---|---|---|
| Language | Python | Python | — |
| Runtime | Container (control plane) | Laptop | deployment only |
| Orchestration | Plain code | Plain code | — |
| Client SDK | OpenAI SDK | OpenAI SDK | — |
| Gateway | Kong | none | base URL |
| Provider | Azure OpenAI | Databricks Serving | base URL |
| Model | GPT-4-class | llama-4-maverick | config value |
# The entire provider surface. Three implementations, no call-site changes. class LLMClient(Protocol): def complete(self, system: str, user: str, max_tokens: int = 800) -> str: ... class OpenAICompatible: # Kong → Azure OpenAI, or any OpenAI-shaped endpoint def __init__(self, base_url, api_key, model): self._c = OpenAI(base_url=base_url, api_key=api_key) # base_url = the Kong route class AnthropicDirect: ... # Anthropic Messages API class DatabricksServing: ... # in-workspace models, no external key
Selected by one environment variable. Two config values separate a corporate deployment from a laptop demo.
7 · Building the mind map practice
Draw it as a ladder, not a web — seven rungs bottom to top — and annotate each rung with three things:
- Who decides it — you, your organisation, or physics (the wire format).
- What it constrains — draw an arrow only where a real constraint exists. There are exactly two: gateway → client, and orchestration → model family.
- Reversibility — how much work to change it later. Model: a config value. Gateway: a base URL. Orchestration: a rewrite. Language: a rebuild.