An agent is not just a model with access to tools. It is a system that repeatedly decides what to do, acts on the world, observes the result and decides whether to continue.

When I evaluate an agent framework, or build an agent from scratch, I want to understand what the model decides and what the surrounding system guarantees. Those boundaries determine whether an agent is inspectable, recoverable and reliable enough to use.

This is my working decomposition of an agent system, with a coding agent as the running example. It is an architectural model, not a claim that every agent needs every component.

1. Start with the execution loop

An agent loop showing the model, harness, tools, observations and verification.

The smallest useful loop is:

  1. Construct the model's context from instructions, task state and observations.
  2. Ask the model to respond or request an action.
  3. Validate and execute the requested tool call.
  4. Record the observation and update task state.
  5. Continue until the task is complete, blocked, or an execution limit is reached.
                  ┌──────────────────────────────┐
                  │ Task, instructions and state│
                  └──────────────┬───────────────┘
                                 ▼
                       Context construction
                                 │
                                 ▼
                           Model decision
                          /              \
                  Final response       Tool request
                                          │
                                  Validate / authorize
                                          │
                                    Tool execution
                                          │
                                  Observation + state
                                          │
                                          └──────► next decision

The model can propose the next action. The harness decides whether that action is allowed, executes it, records what happened and controls whether the loop continues. The distinction matters whenever tools have side effects or a task spans many model calls.

A deliberately minimal implementation looks like this (illustrative pseudocode, not a production-ready runtime):

for step in range(max_steps):
    context = build_context(task, state, recent_observations)
    decision = model.generate(context, tools=tool_schemas)

    if decision.is_final:
        if verifier.accepts(decision, state):
            return decision.output
        recent_observations.append("Completion criteria not met")
        continue

    action = validate_tool_call(decision.tool_call)
    authorize(action, task.permissions)
    result = execute_with_limits(action)
    state.record(action, result)
    recent_observations.append(result)

raise TaskStopped("Step budget exhausted")

There are important omissions here: idempotency, concurrency, error categories, resumability and approval gates. But even this sketch reveals the control points that disappear when we treat the framework as a black box.

2. The model versus the harness

The model selects actions; the harness governs their execution.

ResponsibilityTypically owned by
Interpret task, choose next tool, synthesize resultModel, guided by context
Define tool schemas and available capabilitiesHarness
Build and truncate contextHarness, sometimes with model assistance
Enforce permissions, sandbox actions, cap spendingHarness
Maintain authoritative task state and checkpointsApplication / harness
Run tests and other external verifiersTools / harness
Decide whether completion evidence is sufficientExplicit acceptance logic, evaluators, or a person

A framework may bundle context assembly, retries, permissions, execution limits and state persistence. When evaluating one, I would inspect those defaults and determine which controls the application needs to override.

3. Context is constructed, not remembered

For each model invocation, the system chooses what the model sees: system instructions, task requirements, tool definitions, retrieved documents, recent actions, summaries and sometimes an explicit plan.

These are not interchangeable:

  • Conversation history records what was said and attempted.
  • Task state records what remains to be done and the current authoritative status.
  • External artifacts are the files, database rows, code, or experiment outputs that actually exist.
  • Longer-term memory can preserve reusable facts or preferences across tasks, but it can be stale or wrong.

Consider a coding agent that has made three unsuccessful edits. A compressed conversation might say, “Fixed the parser.” The repository and failing tests may show otherwise. On resumption, files and test results should win over the summary.

A useful context builder should answer: Why was this information included? What was omitted? Is the evidence still current? That requires logging context provenance, not merely token counts.

4. Tools turn model output into side effects

Tool use is a protocol boundary. The model emits a structured request; the harness interprets that request and potentially changes the world.

For a coding agent, tools might read files, modify files, run a test suite, or open a pull request. These have different risks. A read can be repeated freely; applying a patch or posting a comment may not be safe to repeat after a timeout.

I would design the tool layer around:

  • Schema validation: reject malformed arguments and enforce path and value constraints.
  • Authorization: constrain tools by task, user approval, filesystem scope and network access.
  • Execution limits: timeouts, CPU/GPU budgets, token budgets and maximum tool calls.
  • Idempotency and retries: distinguish safe retries from actions that might duplicate side effects.
  • Typed results: report successful output, test failures, timeouts, permission errors and transient errors distinctly.
  • Auditability: keep action, arguments, result and relevant artifact versions together.

A model saying “I ran the tests” is not evidence. A recorded test command, exit code and output tied to a particular commit is.

5. Planning, reflection and multi-agent workflows

Several patterns are commonly grouped under agents, but they make different tradeoffs.

PatternUseful whenFailure mode to watch
ReAct-style step-by-step tool useThe next action depends on observationsLoops, repeated calls, local decisions without global progress
Plan then executeThe task has identifiable stages and dependenciesPlan becomes stale as evidence changes
Generate, evaluate, repairA verifier can cheaply detect failuresOptimizing to the verifier while missing the real objective
Subagents / delegationSubtasks have separable context, tools, or expertiseCoordination overhead, conflicting edits, loss of shared context
Fixed workflow with model stepsA known process needs judgment at specific pointsArtificially restricting cases that do need exploration

I would start with the simplest loop and add an orchestration pattern only when measured failures justify it. More agent roles or more reasoning steps are not automatically better.

6. Durable execution: interruptions are normal

A useful long-running agent has to survive a model timeout, process restart, expired credential, or interrupted human approval. Replaying the entire conversation is not a recovery strategy.

For a coding task, I would persist at least:

task_id
goal + acceptance_criteria
status: pending | running | blocked | completed | failed
workspace / repository revision
current plan or next action
completed actions and tool results
remaining budgets
approval requests
checkpoint timestamp

Resume from the checkpoint, re-read the actual workspace and reconcile completed actions before issuing any new side-effecting tool call. A good resume path is often more important than an elaborate planner.

7. Verification belongs in the architecture

A final answer is an assertion of completion. Different tasks need different evidence.

For a coding agent, verification might include tests, static analysis, diffs, security checks and a human review of intended behavior. For a research agent, it might include source-level citation checking, reproducibility of calculations, data provenance and whether the conclusion actually follows from the evidence.

A separate evaluator can help, but two model calls agreeing is not proof of correctness. A verifier should be selected to detect a meaningful failure mode.

There are at least three things to measure:

  • Outcome quality: did the task satisfy its acceptance criteria?
  • Trajectory quality: did it make unnecessary or unsafe calls, loop, or require intervention?
  • Operational performance: completion rate, latency, token/tool cost and recovery rate after failure.

I would evaluate agent improvements on a set of representative tasks, not only on a compelling demo. A seemingly better prompt might pass one example and regress on harder cases.

8. A concrete trace: fixing a failing test

Imagine the request is: Fix the failing parser test without changing the public API.

StepAgent decision or system actionEvidence and state
1Read failure report and relevant codeTask constraints captured; code revision recorded
2Run the failing testExit code and failure trace stored
3Form a hypothesis and apply a scoped patchDiff recorded against starting revision
4Re-run focused testsTest results associated with patched revision
5Run broader checksRegressions, lint and static checks captured
6Verify API constraint and inspect diffAcceptance criteria checked explicitly
7Return summary or request reviewFinal claim links to test and artifact evidence

Now consider three failure cases:

The test runner times out. This is not the same as a failed assertion. Retry policy should consider whether an action is safe to replay and whether the environment needs repair.

The model declares success after editing. The harness should reject completion until the required evidence exists.

The process dies after applying the patch but before recording the tool response. On restart, the system needs to inspect the workspace before applying the same change again.

These details are what make an agent system an engineering system rather than a long prompt.

9. Where does self-improvement fit?

I separate three ideas that are sometimes conflated:

  1. Retry and reflection within a task: the agent sees an error and revises its approach.
  2. Learning across tasks: observations improve prompts, retrieval, tools, workflows, or policies for future runs.
  3. Recursive self-improvement (RSI): a system proposes changes to its own capabilities or architecture, tests them and adopts changes through a controlled process.

Only the third is a candidate for RSI in the stronger sense and even there the scope of what can change needs to be specified. A generate-test-repair loop does not, by itself, establish durable capability improvement.

An improvement loop should have a held-out evaluator, versioned artifacts, explicit promotion criteria, regression checks and a way to roll back. Otherwise the system may simply learn to exploit its own evaluation.

10. When should I use a framework?

My starting preference is a thin implementation close to the model API. It makes the loop visible and failures easier to localize. I would adopt a framework when I can name the complexity it removes and understand the behavior it introduces.

Before choosing one, I want answers to these questions:

  • Can I see and control the exact context supplied to each model call?
  • Can tasks checkpoint and resume without blindly replaying side effects?
  • Where are permissions, execution limits and approval gates enforced?
  • Can I replace the planner or model without rebuilding task state and tools?
  • What traces and measurements will tell me why a task failed?
  • Which abstractions are essential today and which are workarounds for current model limitations?

Better models may reduce prompt workarounds and rigid decomposition rules. They do not automatically eliminate the need for controlled execution, durable state and evidence of completion.

My design preference: keep the model loop simple, make the harness observable and add orchestration only when failures show that it is needed.

What I was reading

Diagrams generated using AI.