← Back to list

Building Agentic AI Applications with a Problem-First Approach (2026 Update)

Most agentic systems fail for the same reason: the team started with the model instead of the problem. Here is the engineering discipline…

Babak (Bob) Mashouf · 2026-06-11 17:23 · 0 claps · 11.7 min read
#agentic-ai #building-ai-agents #building-ai #ai-orchestration
Open on Medium ↗
Wiki topics: AGT · AI Agents 🚀 · Self Improvement

Building Agentic AI Applications with a Problem-First Approach (2026 Update)

Most agentic systems fail for the same reason: the team started with the model instead of the problem. Here is the engineering discipline that fixes that.

The industry has spent the last two years wiring large language models to tools and calling the result an “agent.” Browsers, code interpreters, calendars, internal APIs, give a sufficiently capable model enough actions and a broad enough prompt, and surely autonomous, employee-like behavior emerges.

It mostly doesn’t. When you audit agentic pilots that never reach production, the failure mode is remarkably consistent. The model was treated as the starting point of the design rather than as one component inside a larger system whose behavior was never specified. In classical software engineering, no one ships a service without first defining its schemas, state transitions, and error boundaries. Yet agentic projects routinely skip straight to “let the LLM figure it out.”

A problem-first approach inverts that order. You define the task, its constraints, and its acceptable failure modes before you decide where a language model belongs. Without that discipline, you are not building an agent. You are building a stochastic loop with no defined exit condition, and then hoping it converges.

This article lays out the engineering methodology for getting from a problem statement to a reliable agentic system: how to price the cost of autonomy, how to layer the architecture, how to choose an orchestration pattern, and how to evaluate and observe the thing once it is running.

Why “Problem-First” Beats “Model-First”

Problem-first vs. model-first approach for agentic AI at a glance:

The model-first instinct is understandable. Frontier models are genuinely capable, and the demos are seductive. But capability is not the same as reliability, and an agentic application lives or dies on reliability.

A model-first design asks: what can this agent do? That question has no natural boundary, so the resulting system has no natural boundary either. A problem-first design asks: what is the exact objective, what is the sequence required to achieve it, and which steps actually require probabilistic reasoning? That question terminates. It produces a specification you can build against and test against.

The practical consequence is that a problem-first system uses the LLM as narrowly as possible — for intent parsing, for synthesis, for the genuinely ambiguous steps — while pushing everything deterministic into ordinary code. This is not a limitation. It is the entire point. The reasoning surface area of your system is also its failure surface area, and you want to minimize it.

The Cost of Autonomy: Three Taxes You Pay Per Turn

Before adding an agentic loop to any pipeline, price it. Autonomy is never free, and the costs compound in ways that are easy to underestimate during scoping.

The latency tax. Every reasoning step adds a full round-trip: model inference, tool execution, and network overhead. A single agentic turn commonly lands in the multi-second range once you account for all three. A task that resolves in five turns can keep a user waiting half a minute. For interactive applications, this is frequently the binding constraint, not accuracy.

The reliability tax. This is the one that sinks projects, and it is pure arithmetic. In a fixed linear chain, end-to-end reliability is the product of each step’s success rate. Two steps at 95% give you roughly 0.95 × 0.95 ≈ 90%. Stretch that to five steps and you are already below 80% before anything “goes wrong.”

In an open-ended agentic loop, the execution path itself is non-deterministic, so the number of opportunities for the trajectory to drift off-goal grows rather than staying fixed. Redundancy and fallback models help, but the baseline math is unforgiving: every probabilistic step you add is another factor below one that you multiply through.

The token tax. Agents are verbose. They generate extended chain-of-thought, re-read tool documentation, retry failed calls, and accumulate context as the trajectory lengthens. Without explicit iteration caps and context-pruning strategies, a single “thinking” run can burn an order of magnitude more LLM tokens than the equivalent deterministic call — and do it repeatedly before it succeeds.

If you internalize one habit from this section: treat each agentic turn as a line item with a latency cost, a reliability cost, and a token cost, and justify it against the alternative of just writing the code.

The Problem-First Framework: Three Layers

A robust agentic application is best understood as three concentric layers. The model is the innermost layer and the last thing you design, not the first.

Layer 1 — The Deterministic Core (the rails)

Start by asking whether you need an agent at all. If the workflow is linear and predictable, an agent is the wrong tool; a retrieval-augmented generation pipeline or a plain decision tree is faster, cheaper, and far easier to maintain. Reserve agency for genuine branching uncertainty.

Whatever portion of the logic is deterministic — business rules, policy checks, eligibility gates, regulatory constraints — belongs in code, expressed as explicit state machines or rule sets. The model should never be the thing that “decides” a policy outcome. It reports outcomes that the deterministic core has already computed. This single rule eliminates a huge class of hallucination risk, because you have removed the high-stakes decision from the probabilistic component entirely.

Layer 2 — The Constrained Tool Surface (the hands)

The reflex to hand an agent a broad toolbox is a mistake. Every tool you expose enlarges the action space the model can wander into, and the size of the action space correlates directly with execution-error rate.

Instead, design narrow, high-utility interfaces with strictly typed inputs and outputs. If an agent needs to check inventory, give it get_stock(sku_id) -> int, not raw database access. If it needs to issue a payment, give it a single endpoint with a validated schema rather than a general-purpose shell. Each tool should do one well-specified thing, validate its arguments, and fail loudly. You are engineering the smallest possible surface through which the model can act on the world.

Layer 3 — The Reasoning Loop (the brain)

Only after the rails and the tools are defined do you introduce the LLM. Its job is narrow: parse messy human intent into structured arguments, decide which constrained tool to call next given the current state, and synthesize results back into natural language. Everything load-bearing happens in the layers beneath it.

This layering is what lets you make a probabilistic component behave deterministically at the level that matters. The conversation feels fluid and adaptive; the policy compliance is hard-coded and provably correct.

Choosing an Orchestration Pattern

Once you have established that a problem genuinely needs reasoning, the next decision is how the reasoning loop is structured. Choosing the wrong pattern for the task is one of the most common causes of non-deterministic failure. The main options, in rough order of increasing structure:

**ReAct (reason + act).** The agent alternates between a thought, an action, and an observation. It is simple and effective for short-horizon tasks, but it is prone to looping when tool outputs are unexpected, because nothing stops it from retrying the same failing approach. Good for prototypes and shallow tasks; risky as a production default.

Plan-and-execute. The agent first generates a full multi-step plan, then executes the steps in sequence. Separating planning from execution gives you markedly more stability on complex goals, because the agent commits to a structure up front instead of re-deciding its strategy at every step and losing the thread mid-trajectory.

Multi-agent critique. One agent produces a candidate output; a second agent audits it against requirements or policy. This generate-and-verify split is the strongest pattern when correctness is non-negotiable and you can afford the extra inference, because the verifier catches the generator’s errors before they reach the user.

Directed graphs. For anything multi-step in production, move beyond a single loop to an explicit graph — planner, executor, validator as distinct nodes with conditional edges between them. Frameworks like LangGraph exist precisely so you can hard-code what happens on failure. When a validator node detects an error, the graph doesn’t hope the agent recovers; it routes deterministically to a designated error-handling node. This is how you claw back control over the reliability tax.

The heuristic: short-lived, low-stakes task → ReAct. Long-horizon, multi-step task → plan-and-execute on a graph. High-stakes output → add a critic. Don’t reach for a multi-agent constellation when a decision tree would do.

A Worked Example: A Document-Intake Compliance Agent

Abstractions get concrete fastest with an example. Consider an agent that ingests inbound vendor documents — invoices, certificates, disclosures — and determines whether each one satisfies a compliance checklist before it enters a system of record.

The model-first version. Hand an LLM the document text and a tool that marks records “approved,” and trust it to apply the checklist from a long prompt. Because the model is probabilistic, it will eventually approve a document that violates a rule, or hallucinate a field that wasn’t present. The failure is silent and expensive, and it surfaces in an audit months later.

The problem-first version, built in the three layers:

Layer 1 — deterministic core. Encode the compliance checklist as an explicit state machine. Is the document type recognized? Is the effective date within the valid window? Are all mandatory fields populated? The pass/fail decision is computed in code from extracted values. The model never adjudicates compliance.

Layer 2 — constrained tools. Rather than raw document access, expose extract_fields(doc_id) -> TypedRecord and lookup_vendor(vendor_id) -> VendorStatus, both returning strictly typed schemas. The model's action space is two well-defined calls, not an open document store.

Layer 3 — reasoning loop. Use plan-and-execute. The planner identifies the document type from messy OCR text. The executor calls extract_fields. The deterministic core evaluates the checklist against the extracted values. The synthesizer turns the verdict into a human-readable explanation: "Rejected — the liability certificate expired 12 days before the effective date."

The high-stakes decision now lives entirely in deterministic code. You get auditable, near-100% policy compliance and a natural-language interface, because each component is doing only what it is reliable at.

Evaluation: The Eval Harness Is the Product

The most common mistake in agent development is shipping on the strength of ad hoc, vibes-based testing. In a probabilistic system, that is not a quality process; it is a hope.

What you need instead is an evals library: a curated set of golden test cases with known-correct outcomes, spanning the happy path, the known edge cases, and the adversarial inputs that have burned you before. Every change to a prompt, a model version, or a tool definition is validated against this library before it deploys. If the success rate on the suite regresses past your threshold, the change does not ship — full stop.

Frame your metrics around problem resolution, not surface accuracy. The questions worth measuring are: what fraction of tasks resolve end-to-end without human escalation, how many turns did resolution take, and what did each resolution cost in tokens and latency. These tie directly to the three taxes and to whether the system is actually solving the problem you started with. Treat evaluation as the backbone of the system rather than a final QA step bolted on before launch.

Observability: You Cannot Debug What You Cannot Trace

Traditional software hands you a stack trace when something breaks. Agentic systems hand you a transcript of probabilistic reasoning, which is a much harder object to debug. Plan for that from day one.

Trace everything, in sequence. Every prompt, every tool call, every intermediate thought needs to be captured under a single trace ID that follows a request through its full lifecycle. Tooling such as LangSmith or Arize Phoenix exists to let you visualize exactly where a trajectory diverged from the expected path. Without end-to-end tracing, a production failure is essentially unfalsifiable.

Watch the reasoning-to-action ratio. If the agent emits a large volume of intermediate tokens per external tool call, the system is inefficient — usually a signal that prompts are ambiguous or tool descriptions are confusing the model. Pair this with hard iteration limits: if a task isn’t resolved within, say, 5–10 turns, the agent escalates to a human rather than burning budget in a loop.

Human-in-the-Loop Is an Architectural Primitive, Not a Fallback

There is a persistent temptation to make agents fully autonomous. Unless the stakes are genuinely zero, resist it. Mature agentic architectures build in interrupts — predefined nodes in the execution graph where the agent pauses and waits for human approval before proceeding.

An agent managing cloud infrastructure can propose scaling up a cluster, but it should never execute a five-figure change without a human approving it through a deliberate action. In practice, building the human-in-the-loop interface is often more work than building the agent’s core reasoning — and it is frequently the only thing that gets the system past security and compliance review.

Design the interrupt points up front; retrofitting them is painful. AI Agent Studio treats HITL as a first-class workflow primitive: interrupt nodes are part of the agent definition itself, integrating natively with enterprise approval and notification channels rather than requiring a separate implementation layer.

Multi-Agent Systems and Model Tiering

When a problem is too broad for a single prompt to hold without losing the plot, decompose it across specialized agents — much as a software team splits into roles. One agent optimizes for high-precision retrieval; another optimizes for synthesis and tone. Separation of concerns improves reliability because each agent has a narrower, more testable mandate.

It also unlocks a real economic lever: model tiering. Route routine, high-throughput subtasks to smaller, cheaper, faster models, and reserve frontier models for the high-level AI orchestration and the genuinely hard reasoning. Because specialized subtasks can often run in parallel, this simultaneously cuts the token tax and the latency tax. Don’t reach for a multi-agent design by default, though — it adds coordination overhead, and a single well-scoped agent is easier to reason about whenever the problem fits inside one.

Conclusion: Architecture Over Autonomy

Building agentic AI is not about granting a model more freedom. It is about surrounding it with enough structure that its probabilistic core becomes reliable in aggregate. The strongest production systems minimize the reasoning surface area: they use LLMs for intent parsing and synthesis, and they leave the load-bearing logic to deterministic code and tightly-scoped APIs.

That is the whole of the problem-first discipline. Start with the problem, not the model. Price the cost of every autonomous turn. Layer the system so the deterministic core owns every high-stakes decision. Choose the orchestration pattern the task actually requires. Evaluate against a golden suite, trace everything, and put a human in the loop wherever the stakes demand it.

Given a capable enough base model — and today’s models are more than capable enough — it is almost never the model that determines whether your agentic application succeeds. It is the architecture around it.

Frequently Asked Questions

What is a problem-first approach to agentic AI?

It is an engineering methodology in which you specify the task, its constraints, and its acceptable failure modes before selecting or wiring up a model. You separate deterministic subtasks (handled in code) from probabilistic ones (handled by an LLM), and introduce the model only where genuine reasoning is required. The alternative — model-first — starts with a capable model and searches for things it can do, which tends to produce unbounded, unreliable systems.

How is an agentic AI application different from a normal LLM integration or a RAG pipeline?

A RAG pipeline or a single LLM call follows a fixed, predictable path. An agentic application introduces a reasoning loop that decides its own next action at runtime, calling tools and reacting to their outputs. That autonomy is powerful but expensive: if your workflow is linear and predictable, an agent is usually the wrong choice, and a deterministic pipeline will be faster and more reliable.

Why do so many agentic AI projects fail in production?

The dominant reasons are the compounding reliability tax (multiplying per-step success rates quickly drops end-to-end reliability), unbounded latency from multi-turn loops, runaway token costs, and the absence of a rigorous evaluation harness. Most of these trace back to a model-first design that never specified the system’s behavior.

Which orchestration pattern should I use — ReAct, plan-and-execute, or multi-agent?

Match the pattern to the task. ReAct suits short, low-stakes tasks. Plan-and-execute gives more stability on complex, multi-step goals. A multi-agent critique pattern is best when correctness is non-negotiable and you can afford a verifier. For most production workflows, an explicit graph with conditional edges and a validator node is the safest structure.

How do I evaluate an agentic AI system?

Build an evals library of golden test cases with known-correct outcomes covering happy paths, edge cases, and adversarial inputs. Validate every prompt or model change against it, and block deploys that regress past a threshold. Measure problem-resolution metrics — end-to-end resolution rate, turns to resolution, and cost per resolution — rather than surface-level accuracy.

How much autonomy should I give an agent?

As little as the problem allows. Push every high-stakes or policy-bound decision into deterministic code, constrain the tool surface to narrow typed interfaces, and insert human-in-the-loop interrupts at any step with real consequences. Reserve the model for intent parsing, action selection, and synthesis.


메타데이터
post_id
07bb895d7641
slug
building-agentic-ai-applications-with-a-problem-first-approach-07bb895d7641
url
https://medium.com/@bob.mashouf/building-agentic-ai-applications-with-a-problem-first-approach-07bb895d7641
canonical_url
https://medium.com/@bob.mashouf/building-agentic-ai-applications-with-a-problem-first-approach-07bb895d7641
author_url
https://medium.com/@bob.mashouf
status
ok
fetched_at
2026-06-24 23:31:39