Skip to content

Lesson 1 of 7 · 5 min read

Reading Any Agent Framework

Free lessonReviewed By the AIAgentInterviews editorial team
Reading position
In this lesson

TL;DR: Underneath, every framework runs the loop you could write in forty lines: send the transcript to the model, execute the tool calls it returns, append the results, check a stop condition. What a framework adds is decisions about that loop. Ask six questions. Control: does the model choose the next step, or a graph you declared? State: what is kept, where, and what survives a crash? Pause and resume: how does a run wait for a person, and what re-runs when it continues? Delegation: does work move between agents by handing over the conversation or by calling an agent as a tool? Integration: how are tools defined, and are MCP and A2A first-class? Visibility: what does a trace show, and can you evaluate runs? A framework that answers these well for your system is worth its abstraction; one that hides an answer you need will cost you in production.

After this lesson, you should be able to see the common loop inside any framework, interrogate a framework with six questions, predict the production surprises each answer implies, and explain to an interviewer why you would or would not adopt one for a given system.

Before you read

Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.

  1. 1A team says 'we use a framework, so our agent is durable'. What would you ask before believing it?

The loop every framework wraps

Here is the mechanism without any framework, with the six seams marked. Each comment is a place where a framework makes a decision for you:

import json

def scripted_model(transcript):
    """Stands in for a model. Turn 1 asks to refund; turn 2 answers."""
    if not any(m["role"] == "tool" for m in transcript):
        return {"tool": "refund", "args": {"order": "A-17", "amount": 40}}
    return {"text": "Refunded 40 on order A-17."}

TOOLS = {"refund": lambda order, amount: f"refund {order} {amount} ok"}   # 5. integration
NEEDS_APPROVAL = {"refund"}

def run(transcript, store, run_id, approved=False, max_steps=5):
    for step in range(max_steps):                         # 1. control: model-driven
        reply = scripted_model(transcript)
        if "text" in reply:
            return reply["text"], "done"
        if reply["tool"] in NEEDS_APPROVAL and not approved:
            store[run_id] = json.dumps(transcript)          # 2. state, 3. pause
            return f"approve {reply['tool']} {reply['args']}?", "paused"
        result = TOOLS[reply["tool"]](**reply["args"])
        transcript.append({"role": "tool", "content": result})
        print("trace:", reply["tool"], result)             # 6. visibility
    return "step budget exhausted", "stopped"

store = {}
print(run([{"role": "user", "content": "refund A-17"}], store, "r1"))
resumed = json.loads(store["r1"])                           # 3. resume from storage
print(run(resumed, store, "r1", approved=True))
# => ('Refunded 40 on order A-17.', 'done')

Delegation (seam 4) is missing because there is one agent. Add a second and you must decide whether the first agent hands the conversation over or calls the second like a tool. That is the fourth question.

The six questions

ASK OF EVERY FRAMEWORK
Six questions that predict production behaviour
  1. Control

    who picks the next step

    • Model-driven loop
    • Declared graph or workflow
    • Both, nested
  2. State

    what is kept and where

    • Conversation, scratch data, memory
    • In memory or durable store
  3. Pause and resume

    waiting for a person

    • Interrupt, approval, request for input
    • What re-runs on resume
  4. Delegation

    work between agents

    • Handoff: the other agent takes over
    • Agent as tool: it returns a result
  5. Integration

    tools and protocols

    • Function tools and schemas
    • MCP servers, A2A agents, UI events
  6. Visibility

    after the run

    • Traces per step and tool
    • Evaluation hooks
The answers differ by framework and by version. The questions do not.

1. Control: who picks the next step?

Some frameworks centre a model-driven loop: you give an agent instructions and tools, and the model decides what to do until it stops (OpenAI Agents SDK, Claude Agent SDK, LangChain's create_agent). Others centre a declared graph: nodes and edges you write, with the model called inside nodes (LangGraph, ADK's graph workflows, Microsoft Agent Framework workflows, CrewAI Flows). Most now offer both and let you nest one inside the other. A graph makes the path inspectable and testable; a loop adapts to cases you did not foresee. The design question is which steps must be fixed (payments, approvals) and which can be left to the model.

2. State: what is kept, where, and what survives?

Distinguish three kinds: the conversation (messages and tool results), working state (fields your code reads and writes, such as a draft or a ticket id), and memory that outlives the run. Then ask where each lives. In-memory defaults are for development. Production needs a durable store, and you should know whether the framework persists after every step or only at boundaries, because that decides what is lost in a crash.

3. Pause and resume: what happens while a person decides?

Approvals take minutes or days. A good framework ends or suspends the run, persists its state, and resumes from storage, possibly in another process, when the answer arrives. The detail to check is what re-runs on resume. In some frameworks the paused step re-executes from its beginning, so any side effect placed before the pause in that step runs twice. That single fact causes real incidents.

4. Delegation: handoff or agent as tool?

A handoff transfers the conversation: the receiving agent talks to the user from then on. An agent as tool is called by the first agent, does a bounded job and returns a result, while the first agent stays in charge. They fail differently: handoffs lose context unless you filter and carry it deliberately; agents as tools can be called in loops and need budgets. Every framework offers at least one, under different names.

5. Integration: tools and protocols

How are tools defined (decorated functions with schemas from type hints, classes, OpenAPI specs)? Are MCP servers first-class, so your agent can use any server without glue code? Can the agent call or be exposed as an A2A agent? Does it emit AG-UI events to a front end? By late 2026 most major frameworks support MCP; A2A and AG-UI support varies.

6. Visibility: what can you see afterwards?

A trace should show each model call with inputs and outputs, each tool call with arguments, results and timing, and the decisions in between, linked to a run id. Ask whether traces use OpenTelemetry or a vendor format, whether you can run evaluations against recorded runs, and whether sensitive data can be redacted before export.

Reading the answers

Answer you findProduction implication
State only in memory by defaultAdd a durable store before the first long-running workflow
Paused step re-runs from its startPut side effects after the pause, or make them idempotent
Handoff passes the full historyFilter what the next agent sees; history can carry injected text
Tools defined from docstrings and type hintsThe docstring is now part of the model's prompt: review it like one
Traces in a vendor format onlyPlan the export path before an incident needs it

The misconception interviewers listen for

"We picked the framework, so the hard parts are done." A framework decides mechanics: how the loop runs, how state is stored, how events are emitted. It does not decide what the agent may do, which tool calls need approval, what a good result is, or how much a run may cost. An interviewer asking "why this framework?" wants the six answers and what you still had to build, not a feature list.

Say it in 30 seconds

"Every framework wraps the same loop: model call, tool execution, state, stop condition. I read one with six questions: who drives control flow, a model loop or a declared graph; what state is kept, where, and whether it survives a crash; how a run pauses for a person and what re-runs on resume; whether delegation is a handoff of the conversation or an agent called as a tool; how tools, MCP and A2A plug in; and what traces and evaluations I get. The answers predict the production surprises, like side effects repeating on resume or handoffs carrying injected history, and they make clear what the framework leaves to me: authority, approvals, evaluation and cost limits."

Check yourself

Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.

  1. 1Name the six questions for reading an agent framework.

  2. 2A framework resumes a paused step by re-running it from the top. The step charges a card and then asks for approval of the shipping method. What goes wrong, and how do you fix it?

  3. 3What is the practical difference between a handoff and an agent used as a tool?

Practise it as an interviewer asks it

Related lessons