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.
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.
| 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 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.
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.
βThe model says it is doneβ is not a completion criterion. Use a verifier that can inspect the target state:
Design an agent that updates API documentation after a route changes.
Checkpoint: remove the model from your design. The remaining system should still make permissions, evidence, and completion understandable.
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.
Use coding agents safely from repository inspection through focused implementation, verification, and review.
Turn an AI-assisted business process into a bounded, reviewable workflow with evidence, approvals, and safe stopping conditions.
Core techniques for writing effective prompts for LLMs.