Agent Engineering Results Depend on System Design

    Reliable agents usually fail because reasoning, state, and boundaries are mixed together—not because the model is too weak. This article explains how control flow, context engineering, tool design, memory, multi-agent coordination, evaluation, tracing, and safety determine what the model sees, what it can call, how failures recover, and how teams prove a change actually improved results.

    Workflows and Agents Are Not the Same Thing

    When the execution path is written in advance, the system is closer to a workflow: branches, retries, and human steps all live in code. A system is closer to an agent only when the model decides at runtime which capability to call next and whether to continue. Neither form is inherently better. What matters is who holds control.

    Fixed approvals, batch extraction, and tightly regulated pipelines are more predictable as workflows, and their cost is easier to estimate. Open-ended troubleshooting, cross-system retrieval, and tasks that must change the plan based on intermediate results are the cases worth handing the next step to a model. Many products labeled “agents” are still workflows with a few large-model nodes. That is not a failure. Naming the shape correctly avoids using dynamic decisions for problems that should be hardcoded, and avoids forcing a rigid flow onto an open task.

    Keep the Main Loop Short and State Outside It

    Perception, decision, action, and feedback can collapse into one stable loop: place the user input in the message sequence; if the model requests tools, run them and write the results back; if it returns only text, stop. After that abstraction, the loop itself can stay short. Subtask delegation, context compression, and skill loading belong outside the loop, not inside a huge state machine.

    Split responsibility this way: the model handles reasoning and the next choice; external systems handle state, quotas, timeouts, and permissions. New capability enters through only three paths: extend tools and their handlers, adjust the structure of the system prompt, or put state in files or a database. Once the loop absorbs too many business branches, every requirement change touches stop conditions, retries, and message formats, and regression cost rises quickly.

    The sketch below shows responsibilities only. It is not tied to any specific interface:

    1. messages = [user_input]
    2. loop:
    3. response = model(messages, tool_specs)
    4. if response.asks_for_tools:
    5. results = run_tools(response.tool_calls) # timeouts, permissions, and audit live here
    6. messages.append(assistant_turn)
    7. messages.append(tool_results)
    8. else:
    9. return final_text(response)

    Stop conditions must be explicit: plain-text completion, a step or token limit, user cancellation, repeated tool failure, or a policy rejection. An implicit “the model will stop on its own” is unreliable in production.

    Context Engineering Decides What the Model Can Actually Use

    Context is not “stuff the whole history in.” The window is limited. Irrelevant content dilutes instructions, and stale tool results can induce the same mistake again. Separate a few kinds of information: the current task and constraints, recent dialogue, this turn’s tool results, retrievable long-term material, and sensitive fields that must not enter the prompt.

    Practical tactics include trimming history by relevance; summarizing long tool output in a structured form while keeping a traceable identifier; keeping stable rules on the system side and volatile facts in retrieval or state storage; and using different prompt skeletons for different stages instead of one ever-growing master prompt. Compression must be reversible or checkable. Otherwise you cannot explain, during debugging, why the model missed a critical fact.

    A more expensive model often helps only a little, because the bottleneck is whether the context it sees is correct. On the same loop, cleaner prompt partitions and result trimming often change success rate more than a spec upgrade alone.

    Tool Design: Descriptions Fail More Often Than Implementations

    Most wrong tool choices come from vague names, parameter descriptions, and boundaries, not from broken handler logic. The model can choose only from the description. A description should state what problem the tool solves, what it does not solve, what each parameter means and its units, what it returns on failure, and whether it has side effects. Similar tools should be deliberately differentiated so two descriptions cannot both “sort of” cover the same intent.

    The handler side owns determinism: input validation, idempotency, timeouts, rate limits, and error classification. Business state should not hide in model memory. It should land in the tool or in external storage. When debugging, first check whether the tool definition matches real behavior before suspecting that the model is “not following instructions.” A description that promises read-only behavior while the implementation writes, or parameter names that contradict the examples, will reliably produce bad choices.

    Prefer fewer, harder tools. If one query with clear parameters can do the job, do not split it into a chain of overlapping actions. When composition is needed, keep it in a skill or preset flow outside the loop, and still expose it to the model through an explicit tool.

    Memory: Short-Term in Messages, Long-Term Outside the System

    Recent turns inside a conversation are short-term memory. They are the right place for the trace of decisions. Preferences, project facts, and verified conclusions that span sessions are long-term memory. Store them outside the conversation, with time, source, and expiry conditions. Writes need a threshold: unconfirmed guesses, one-off error reports, and raw text that contains sensitive information should not enter long-term memory by default.

    Retrieve by task. Do not inject the full store on every turn. When memories conflict, prefer the authoritative source and the newer timestamp, and mark in the prompt that a fact may be stale. Memory without an expiry policy makes an agent more confident on the wrong facts the longer it runs.

    Multi-Agent Organization: Split by Responsibility, Not by Noise

    Multiple agents help only when responsibility boundaries are clear—for example, retrieval, execution, and review kept apart, with the reviewer not sharing the executor’s hidden drafts. Copying the same context to several roles that restate each other raises latency and cost while errors reinforce one another.

    Coordination should stay simple: a controller assigns subgoals, limits each sub-agent’s tool set, and defines the return format. Sub-agents should not freely spawn more sub-agents, or tracing and permissions get out of hand. Share state through external storage, not by hoping they “remember what the other said in the chat” as a bus.

    Evaluation and Verification Are Often Worth More Than Rewriting the Loop

    Agent behavior is stochastic. A single demo does not prove a regression. You need a fixed task set, success criteria that can be judged automatically, and cases that cover tool failure, permission denial, and insufficient information. Judge observable results where possible: whether a file matches the spec, whether a query hits, whether an answer satisfies the constraints—not only the model’s self-assessment.

    The evaluation system itself breaks: stale labels, overly loose judges, cases that leak the answer, and environments that do not match production. If scores stay flat for a long time or suddenly go all green, suspect the evaluation before tuning prompts inside the loop. Only when verification is solid can a model swap’s gain be measured. When verification is vague, a more expensive model mainly packages uncertainty more fluently.

    Treat repeatable tasks and judgments as assets at the same level as the main loop. Without them, changes to context and tools cannot be attributed.

    Tracing: You Can Change the Next Step Only If You Can Explain This One

    Each run should record a summary of the messages the model saw, tool names and arguments, latency, error category, stop reason, and whether evaluation passed. Sensitive content must be redacted. The point of tracing is not to pile up logs. It is to answer whether a wrong tool choice came from the description, missing context, or permissions and timeouts.

    Sampling production runs back into the evaluation set turns real failures into regressions. Without traces, teams tend to keep trying prompt edits that cannot be compared.

    Safety and Boundaries

    Least privilege, tool allowlists, confirmation for writes, and isolation between the prompt and tool results are policies outside the loop. Do not expect the model to follow them on its own. Untrusted content—web pages, tickets, uploaded files—must not rewrite system rules or expand tool permissions by default. Quotas, step limits, and human takeover are part of availability and part of safety.

    A Check Order for Production Issues

    When something breaks, do not start by swapping the model. Check in this order: whether tool descriptions match the implementation; whether context mixed in stale or irrelevant results; whether stop and retry behavior is explicit; whether memory stored something that should not persist; whether evaluation can actually tell right from wrong; whether tracing can point to a specific step; and whether permissions are too broad. After those are stable, decide whether a stronger reasoning spec is needed.

    Keep the main loop small. Let capability enter through tools, prompt structure, and external state, and close the feedback loop with evaluation and tracing. Agent quality then becomes explainable and regressable, instead of depending on one lucky generation.