Frameworksframeworksabstractionlanggraphlangchaintooling

Frameworks: What They Abstract and What It Costs

Agent frameworks package prompt templates, tool registries, loops, state graphs, memory and tracing; the abstraction saves boilerplate and costs visibility, and the right choice depends on which you need more.

Interview question
Progress

You have not marked these as done yet. Read on anyway if they feel familiar; come back to them if something here does not land.

Key points

  • A framework is six things: prompt templates, tool registries, a loop, state graphs, memory, tracing; evaluate each against writing it yourself.
  • Low-level libraries give primitives and visibility; mid-level runtimes give state graphs; high-level frameworks give autonomy and hide prompts.
  • Abstraction costs: hidden prompts, opaque loops, version churn, and conceptual lock-in.
  • Choose the architecture first, then the lowest abstraction level that implements it.
  • Non-negotiables: printable prompts, hard limits, traces with your own tool names.

What a framework actually provides

Strip the marketing and every agent framework is a bundle of six things you would otherwise write yourself. Knowing the list lets you evaluate a framework by asking, for each item, whether its version is better than the fifty lines you would write and whether you need it at all.

  • Prompt templates: composing system prompts, few-shot examples and variable substitution; sometimes with versioning.
  • Tool registries: turning functions into JSON schemas, dispatching model tool calls to code, validating arguments (Tool Schemas).
  • The loop: the model → tool → model iteration from The Agent Loop, with retries and step limits of varying quality.
  • State graphs: explicit nodes and edges for Workflow State Graph designs, with persistence and resumption.
  • Memory: conversation buffers, summarisation, vector-backed recall (Memory Architectures).
  • Tracing: spans for model and tool calls, usually integrated with the vendor’s observability product (Tracing Agents).

Abstraction levels

Frameworks sit at three levels, and the level matters more than the brand. Low-level libraries (typed model clients, schema helpers, the Vercel AI SDK, Pydantic AI) give you primitives and leave the loop to you; you see every prompt. Mid-level graph runtimes (LangGraph, Google ADK, Microsoft Agent Framework) give you an explicit state machine with persistence; the control flow is yours, the plumbing is theirs. High-level agent frameworks (CrewAI, LangChain agents, OpenAI Agents SDK in its default mode) give you roles, tasks and an autonomous loop; you write descriptions and the framework writes the prompts.

The higher the level, the faster the demo and the harder the production incident. Each level is the right choice for some team; the failure is picking a high-level framework for a system that needs low-level control, or writing a graph runtime from scratch when one exists. The Framework Explorer at /agentic/frameworks compares the individual frameworks along these axes with code samples.

Abstraction levels and what you control
LLM SDK + your codeLow-level: clients, schemasYou control prompts and loopMid-level: state graph runtimeHigh-level: roles and crewsFramework controls prompts and loop
UserLLMAgentToolDataDecisionHumanGuardrail

The cost of abstraction

Hidden prompts. High-level frameworks inject their own system prompt text: role descriptions, formatting instructions, tool-use scaffolding. You did not write it, you cannot easily see it, and it changes between versions. When the agent misbehaves, the cause may be a sentence you have never read. When you tune your prompt, you are tuning a fraction of what the model sees.

Hard-to-debug loops. A framework’s loop has its own retry logic, its own termination condition and its own error handling. When it loops or stops early, the trace shows framework internals, and the fix may require monkey-patching. The bounded loop from Budgets, Limits and Termination is trivial to write and to reason about; a framework’s equivalent is a configuration flag whose semantics you must look up.

Version churn. The field moves fast and frameworks move with it: renamed modules, deprecated agent classes, breaking changes in minor versions. A system built on a high-level abstraction inherits an upgrade treadmill; pinning versions inherits a security and model-support freeze. Low-level libraries churn less because they wrap fewer opinions.

Lock-in of concepts, not just code. Once the team thinks in “crews” and “tasks”, redesigning as a plain workflow feels like a rewrite even when it is a simplification. Choose abstractions you could remove.

How to choose

Start from the architecture, not the framework (Choosing the Right Abstraction). If the design is a single LLM call, structured output or a short tool loop, Option 0: No Framework applies and a framework adds only cost. If the design is a persistent, resumable state graph with human approval steps and parallel branches, a mid-level runtime saves real engineering. If you need a demo tomorrow and will throw it away, a high-level framework is fine, as long as everyone agrees it will be thrown away.

Whatever you pick, insist on three properties: you can print every prompt the model receives, you can set hard step and cost limits, and traces show your own tool names rather than framework internals. A framework that fails any of these will fail you in production.

When to use — and when not to

Use it when
  • Mid-level graph runtimes for persistent, resumable workflows with approval steps and parallel branches.
  • Low-level SDKs and schema helpers for almost every tool-calling system.
  • High-level frameworks for disposable prototypes and internal demos.
Avoid it when
  • Do not adopt a high-level framework for a system with security or compliance requirements you must be able to explain.
  • Do not pick a framework before the architecture is decided.
  • Do not use a framework’s memory or RAG defaults in production without evaluating them against a plain implementation.

Failure modes

Reference · show
  • A hidden framework prompt tells the model to “be helpful and complete the task at all costs”, overriding your refusal rules.
  • The framework loop has no cost cap; a demo pattern ships and one request costs $40.
  • A minor version upgrade renames the agent class and breaks production on deploy day.
  • Traces show AgentExecutor.step forty times and nobody can tell which tool ran.
  • The team cannot answer “what exactly did the model see?” during an incident.

Tradeoffs

Complexity
low → high
Latency
low → high
Cost
low → high
Reliability
poor → strong
Debuggability
hard → easy

Ratings for a typical high-level framework; low-level libraries score close to no-framework.

Check yourself

Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.

  1. An agent works well in demos but fails unpredictably in production. How would you investigate it?

    Show a strong answer

    First make failures observable: per-run traces with every LLM call, tool call, arguments, results, latencies, and token counts, tagged with a run id. Without that, "unpredictable" just means "unobserved". See Tracing Agents and Trace Inspection: Debugging from a Trace. Then sample failing runs and classify them: wrong tool or arguments, tool errors and timeouts, retrieval misses, context overflow, iteration cap hit, injected content, or a correct process with a wrong final judgement.

    Demos use curated inputs; production has long messages, typos, multiple intents, unusual document formats, and adversarial content. I compare the input distribution and build a golden set from real failures. Production also introduces infrastructure differences: rate limits and 429s, slower tools causing timeouts, concurrency, stale caches, and different data (an empty result set the demo never hit). See Failure Scenarios: Detection and Runbooks.

    Each failure class gets a targeted fix and an eval that would have caught it; I do not touch the prompt until I know which class dominates.

    Full interview question, with follow-ups and red flags →
  2. When would you choose a workflow over an autonomous agent?

    Show a strong answer

    I choose a workflow whenever I can enumerate the steps and their order ahead of time, which is most business processes: extract fields, validate, look up, decide, act, notify. Each step is a node with a typed input and output; some nodes are LLM calls, most are code. See Workflow State Graph and Business Process Automation.

    The reasons are operational. A workflow has bounded cost and latency, each node is unit-testable, intermediate state is inspectable, retries are local to the failing node, and a wrong output can be traced to a specific step. An agent offers flexibility I do not need if the steps are known, and charges for it in variance and debugging time.

    When one step genuinely needs open-ended reasoning, I keep the workflow and make that node a bounded agent with its own iteration cap and tool set. The rest of the system stays deterministic.

    Full interview question, with follow-ups and red flags →
  3. You have no tracing in production. What is the first step?

    Show a strong answer

    Add it: run ids, spans per LLM and tool call with inputs, outputs, latency, tokens; sample-based if volume is high; then collect for a week.

    Full interview question, with follow-ups and red flags →