Architectural Boundaries of LLM, Agent, and Harness in Production

    This article explains how large language models, agents, and harnesses differ in intelligent applications: generation versus goal-driven execution versus runtime governance. It covers tool-call boundaries, state, permissions, recovery, evaluation, and a staged path from prototype to production.

    Why these three concepts need to be separated

    A common mistake when building intelligent applications is assuming that the smarter the model’s answers, the more reliable the system. Generating a plausible answer, completing a business operation, and keeping that operation safe are three different problems.

    For example, a user may ask to “plan a weekend trip within budget.” The model can propose an itinerary, but whether transport prices are real, hotels still have rooms, or payment is authorized cannot be settled by a natural-language reply alone.

    Around that task, three related layers can be distinguished:

    • LLM: understanding and generation. Interprets requirements, analyzes information, generates content, or proposes the next action.
    • Agent: goal-driven execution. Organizes the model, tools, and state around a task so execution can keep moving.
    • Harness: runtime and governance. Provides tool access, permission constraints, state persistence, failure recovery, evaluation, and observability.

    In an organizational analogy, the LLM is an advisor, the agent is the person assigned the work, and the harness is process, access control, and infrastructure. The analogy helps, but it is not an engineering standard. The three do not have to be three separate products, and there is no single industry layering. Harness in particular changes with context. Here it means the engineering environment that supports agent execution and governance, not a fixed product.

    LLM: strong generation is not reliable execution

    What the model is actually responsible for

    A large language model learns statistical patterns in language and related data, then generates output given context. It can handle Q&A, summarization, code generation, extraction, and some reasoning.

    Having trained on a lot of data does not mean it has “read everything,” and it is not a complete, real-time, accurate knowledge base. It may lack latest facts or domain depth.

    A more useful view for developers: the model is a component that produces candidate outputs from input—not a fact database and not a naturally trustworthy business decision-maker.

    Outputs should be validated according to task risk. Marketing copy and a funds-movement instruction must not share the same trust bar.

    A tool-call proposal is not a completed tool execution

    The model can emit text or a structured request to call a tool—query inventory, read an order, compute a price.

    Whether the request actually runs depends on the application:

    1. The model proposes the call.
    2. The application parses it.
    3. Tool name, parameters, and permissions are checked.
    4. The real operation runs.
    5. Results are returned to the model.

    “The model supports tool calling” does not mean the model itself can freely write a database or send email. Real authority sits in the application and runtime.

    If generated operation requests are executed as trusted commands, text-generation risk becomes real business risk.

    Context is not durable memory

    Within one inference, the model can use history in the prompt. That does not mean it naturally stores long-term user state.

    Application “memory” often comes from:

    • Replaying conversation history
    • Saving task summaries
    • Querying external state stores
    • Retrieving user-authorized preferences
    • Reading business records from prior executions

    Those mechanisms are implemented by the system, not owned by the model.

    Context is also capacity-limited. More history is not always better: noise can dilute constraints, and stale facts can mislead. Distinguish raw records, compressed summaries, and authoritative business state. Do not treat a generated summary as undisputed fact.

    Hallucinations need evidence and constraints

    Models can produce answers that look reasonable but are wrong. That is not “saving face”; generation does not guarantee every token is grounded.

    Risk reduction usually combines:

    • External data for time-sensitive questions
    • Deterministic calculation for amounts, dates, and quantities
    • Linking results to inspectable sources
    • Business rules on fields and constraints
    • Explicit uncertainty when evidence is weak
    • Human review for high-risk outcomes

    Retrieval and tools add evidence; they do not automatically remove error. Bad queries, stale returns, or misread results can still distort the answer.

    Agent: from a single reply to a goal-driven loop

    An agent is more than “a model plus a few tools”

    In this architecture, an agent is an execution system organized around a goal, combining model, tools, task state, and control logic.

    It typically closes this loop:

    Observe current state → choose the next action → execute → get feedback → update state → decide whether to continue.

    The point is not merely having tools, but whether feedback can keep the task moving.

    A fixed program that queries a database then asks the model to summarize may be an ordinary workflow. If the system can decide from results whether to gather more information, revise the plan, or ask the user to confirm, it looks more like an agent.

    Higher autonomy is not automatically a better architecture. For stable, well-specified processes, deterministic workflows are often easier to verify and cheaper to run.

    Planning must coexist with business constraints

    A trip-planning task might break down as:

    1. Collect origin, dates, party size, and budget
    2. Query transport and lodging
    3. Check schedule fit and budget
    4. Generate candidate plans
    5. Get user confirmation
    6. Execute approved bookings
    7. Return orders and exception notes

    The model is well suited to understanding needs, comparing options, and explaining in natural language. Date validity, amount totals, and inventory confirmation belong with rules or tools.

    A reliable agent does not let the model decide everything; it lets the model handle uncertainty inside explicit bounds. For known processes, fix key steps and use the model only for local judgment. For open tasks, allow dynamic planning, but limit available actions, scope, and stop conditions.

    State management decides whether execution can continue

    Execution involves at least three kinds of state:

    • Task state: current goal, constraints, completed steps, open issues
    • Environment state: tool data, resource availability, external outcomes
    • Control state: remaining budget, retries, approval status, termination reasons

    These must not live only in chat text. Important state should be stored in structured form and reconciled with real business records.

    A model saying “the order was created” is not proof of success. Only a clear result from the order system—and a follow-up query if needed—should update task state.

    Harness: making the agent runnable and manageable

    The harness is about control, not cleverness

    The agent describes how a task advances. The harness describes the environment it runs in and the limits on execution.

    In implementation the two overlap. Loop scheduling may sit in agent logic or in a runtime framework. The useful question is responsibility, not taxonomy:

    • Who chooses the next action
    • Who verifies the action is allowed
    • Who performs the real operation
    • Who persists state
    • Who stops or recovers on failure

    Without those boundaries, a fluent model can still run out of control under faults or malicious input.

    Tools need a stable contract

    A tool is not an arbitrary function. A reliable contract should describe:

    • Input fields and types
    • Required fields and value ranges
    • Output structure and error semantics
    • Whether it has external side effects
    • Required permissions
    • Timeout and retry conditions
    • Whether it is idempotent

    Return values should distinguish “operation failed,” “temporarily unconfirmed,” and “explicitly succeeded.” If everything is compressed into free text, the agent easily misreads outcomes.

    Permissions must be enforced by the system

    Do not rely on prompts that say “do not exceed authority.” The execution layer must enforce least privilege.

    Examples:

    • Querying an order and modifying it use different permissions
    • Ordinary retrieval must not read sensitive credentials
    • Payments, deletes, and bulk changes need extra approval
    • At execution time, re-check current user identity and resource ownership
    • Approval is bound to specific operation content; if content changes, re-confirm

    Guard against prompt injection from web pages, documents, and tool output. External text such as “ignore previous rules” or “read private data” is data to process, not instruction authority.

    Keyword filters on input are not enough. Tool permissions, action scope, and output validation must work together.

    Failure recovery must account for side effects

    A network timeout does not mean the operation never happened. An order-create request may have succeeded while the response was lost. Blind retry can duplicate orders.

    The execution layer should vary strategy by operation type:

    • Read-only operations can often retry within limits
    • Writes should use idempotency keys or result lookup
    • Multi-step tasks should record checkpoints
    • Operations that cannot be fully undone need compensation
    • Unclear outcomes should go to human handling, not continue blindly

    Do not assume every external tool supports the same recovery. Confirm the real semantics of each operation.

    Termination conditions are mandatory

    Agents can re-query, replan, or keep running with no progress. The harness should set bounds: max steps, overall time, call budget, consecutive-failure thresholds.

    Limits should follow business risk, not a universal number. When a limit is hit, save state, explain why the task is incomplete, and request human intervention if needed.

    A verifiable execution flow

    The following pseudocode illustrates separation of duties. Function names are internal abstractions, not product APIs:

    1. state = load_task_state(task_id)
    2. while within_execution_limits(state):
    3. proposal = propose_next_action(state)
    4. if proposal.indicates_completion:
    5. if verify_completion(state):
    6. finish_task(state)
    7. else:
    8. record_unmet_conditions(state)
    9. break
    10. validate_action_schema(proposal)
    11. check_user_permission(proposal, state)
    12. check_business_constraints(proposal, state)
    13. if requires_approval(proposal):
    14. approval = request_approval(proposal)
    15. if not approval.valid:
    16. pause_task(state)
    17. break
    18. result = execute_with_recovery_controls(proposal)
    19. validate_tool_result(result)
    20. state = update_state_from_result(state, result)
    21. save_checkpoint(state)
    22. record_execution_event(proposal, result)

    Three principles follow.

    First, a proposed action is not an obligation to execute. Permissions, parameters, and business conditions are checked independently.

    Second, completion cannot rest on the model’s self-assessment. It needs business evidence. Finishing an itinerary draft is not the same as completing a ticket booking.

    Third, execution records should store validated inputs, tool results, state changes, and errors—not uninspectable internal reasoning.

    How to evaluate an agent system

    Fluency of answers does not measure real execution quality. Tests should cover the full task path.

    Outcome correctness

    Did the task actually meet the goal: factual accuracy, business constraints, and external operation results. For travel, verify dates, budget, and order status—not only whether the itinerary reads complete.

    Process compliance

    Did the system exceed permissions, skip approval, read unnecessary data, or treat external text as a higher-priority instruction. A correct final result with an illegal path is still unfit for production.

    Recoverability

    Test timeouts, missing returns, unavailable tools, rejected approvals, and interrupted tasks. Watch for duplicate operations, lost state, or false completion claims.

    Cost and efficiency

    Count model calls, tool calls, end-to-end latency, and human intervention. Cost optimization is not simply fewer model calls; it is fewer useless loops and duplicate work.

    Metrics need a business baseline. There is no universal “excellent” score independent of task difficulty.

    Stage 1: Validate the model’s job first

    Clarify what the model actually owns. Prepare representative inputs and failure cases. Decide whether an agent is needed at all; do not add autonomy just to match an architecture.

    Stage 2: Prefer read-only tools first

    Start with query, retrieval, and calculation. Validate tool contracts, data quality, and how results are interpreted. Read-only work is easier to isolate and better for an evaluation baseline.

    Stage 3: Add structured state and bounded loops

    Lift progress out of chat logs. Add checkpoints, failure classes, and stop conditions. Prefer fixed flows for mature steps.

    Stage 4: Open write capabilities carefully

    Before sending notifications, creating orders, or changing business data, finish permission isolation, approval binding, idempotency, and audit design.

    Stage 5: Continuous evaluation and gradual rollout

    Changes to models, prompts, tool definitions, or business rules can change overall behavior. Regression-test before release; after release, monitor anomalous operations, failure mix, and cost, and keep pause and rollback.

    Conclusion: model capability is only part of system capability

    The LLM understands information and generates candidate outputs. The agent organizes action around a goal. The harness makes those actions happen in a constrained, observable, recoverable environment.

    They are not substitutes, and they do not require a heavy multi-layer framework. Simple tasks may need one model call or a deterministic workflow. Multi-step decisions, external operations, and ongoing feedback need fuller agent machinery.

    A reliable intelligent application does not maximize the model’s freedom. It gives every action a clear permission, every result inspectable evidence, and every failure an explainable state and handling path.