Learning Hub
← AI & Machine Learning

AI Agent Fundamentals: From Goal to Verified Result

10 min readΒ·Updated 2026-09-07

Understand the agent loop, the role of tools and memory, and the controls that turn model output into verified work.

An AI agent combines a model with context, tools, and a control loop. The model proposes the next action; the surrounding system decides what is allowed, executes the tool, returns evidence, and determines whether work should continue.

The agent loop

sequenceDiagram
    participant U as User
    participant O as Orchestrator
    participant M as Model
    participant T as Tool
    U->>O: Goal and constraints
    O->>M: Relevant context
    M->>O: Proposed action
    O->>O: Validate permission and arguments
    O->>T: Execute bounded action
    T-->>O: Result or error
    O->>M: Evidence
    M-->>O: Continue, revise, or finish
    O-->>U: Verified result

The model is only one part of the system. Reliability depends heavily on the orchestrator, permissions, tool contracts, and completion checks around it.

Learning outcomes

  • Explain each stage of an agent loop.
  • Distinguish context, working state, and durable memory.
  • Choose tools with narrow, observable contracts.
  • Define completion independently from model confidence.

The five building blocks

Block Responsibility Typical failure
Goal Defines the desired state Broad request with no evidence
Context Supplies relevant facts and constraints Stale or excessive information
Model Chooses or proposes the next action Plausible but unsupported decision
Tools Read or change the environment Permission or argument too broad
Control loop Validates, retries, stops, and reports Infinite loop or false completion

Context is not memory

Context is information available for the current decision. Working state tracks what has happened during the current task. Durable memory survives between tasks. Mixing them causes stale decisions and accidental retention.

Store durable information only when it will remain useful, has a clear owner, and is safe to retain. Retrieve it selectively rather than loading everything at the beginning of every task.

Tools should expose narrow actions

Prefer getOrder(id) and draftRefund(id, amount) over an unrestricted shell or database connection. Narrow tools make authorization, validation, logging, and testing easier.

A good tool result contains structured evidence:

{
  "status": "drafted",
  "refundId": "rf_123",
  "requiresApproval": true,
  "amount": 42.00,
  "currency": "USD"
}

The agent can reason about these fields without guessing whether an operation succeeded or already affected a customer.

Completion needs an external check

β€œThe model says it is done” is not a completion criterion. Use a verifier that can inspect the target state:

  • code compiles and focused tests pass;
  • a generated document contains required sections;
  • a database record exists with the expected status;
  • a reviewer approved a preview;
  • a tool returned the required identifier and audit record.

Practice: specify a documentation agent

Design an agent that updates API documentation after a route changes.

  1. Goal: update only the affected endpoint page.
  2. Context: route handler, request/response types, current page, writing guide.
  3. Tools: read repository files, write a draft, run documentation checks.
  4. Boundary: no deployment, no unrelated formatting changes.
  5. Evidence: diff, passing link/code-example checks, and a preview URL.
  6. Stop: conflicting types, missing authorization behavior, or two failed checks.

Checkpoint: remove the model from your design. The remaining system should still make permissions, evidence, and completion understandable.

Common misconceptions

  • An agent is just a longer prompt. Tools and the control loop change what the system can observe and do.
  • More autonomy means more value. Autonomy is useful only inside tested boundaries.
  • Memory fixes missing context. Uncurated memory can amplify stale or private information.
  • A successful tool call proves the task. It proves one action, not the final outcome.

Definition of done

  • Every tool has a narrow contract and permission boundary.
  • Context, working state, and durable memory are separated.
  • Errors have retry limits and escalation behavior.
  • Completion is checked against observable state.
  • The user receives evidence, not only a summary.

Source note

The core loop was synthesized from AI Agents Full Course 2026: Master Agentic AI (2 Hours) [EsTrWCV0Ph4].en.srt, represented by an English/Vietnamese pair in web-content covering 00:00:00–02:13:15. The system decomposition, tool contract example, and documentation-agent exercise are editorial additions.