Agent Fundamentals#

An AI agent is a model that can choose and use tools repeatedly to finish a goal.

Short video#

AI Agents Explained β€” Tech With Tim (22 min, July 2026)

Agent vs chatbot#

ChatbotAgent
Usually produces one responseCan take several steps
Mainly returns textCan search, calculate, edit, or call APIs
User guides each turnAgent chooses the next step
Low autonomyControlled autonomy

The agent loop#

flowchart LR
    G[Goal] --> D[Decide next step]
    D --> T[Use a tool]
    T --> O[Observe result]
    O --> D
    D -->|Goal complete| F[Final answer]

An agent repeats three simple actions:

  1. Decide: choose the next useful action.
  2. Act: call a tool such as search, calculator, or database.
  3. Observe: read the result and decide whether to continue.

Main parts#

PartPurpose
GoalDefines what β€œdone” means.
ModelChooses the next action.
ToolsLet the agent interact with other systems.
StateKeeps the current task, results, and progress.
RulesLimit permissions, steps, time, and cost.
VerifierChecks whether the result is correct.

Common patterns#

  • ReAct: decide, act, observe, and repeat.
  • Plan then execute: make a short plan before starting.
  • Router: send each request to the right tool or specialist.
  • Human approval: pause before sending, paying, deleting, or publishing.

When to use an agent#

Use an agent when the next step depends on information discovered during the task.

Use normal code when the steps are already known. A fixed workflow is usually faster, cheaper, and easier to test.

Build a minimal agent#

Start with a one-tool, read-only agent. Write its run contract before writing a prompt or choosing a framework:

goal: "Find three official announcements from this week and write a 150-word digest."
tools: [web_search]
max_tool_calls: 6
max_elapsed_seconds: 90
must_return: [three_source_urls, 150_word_digest]
done_when: "Three official URLs and a digest are present."
approval_required_for: []

The goal, limits, and done_when rule are application dataβ€”not an informal model promise. Save a small run record so a retry knows what has already been checked:

{"task_id":"digest-042","sources":[],"tool_calls":0,"status":"running"}

Choose an autonomy level#

LevelEnableExample gate
SuggestRead and draft onlyHuman copies the answer
AssistSafe read-only toolsReturned source URLs are checked
Act with approvalPrepare a write, then stopSigned approval ID is required
Limited autonomousPre-approved low-risk writesIdempotency key and audit log are required

Use the lowest row that completes the task. Do not let a prompt decide whether to send, delete, pay, publish, or deploy; make the write tool require the gate.

Test the agent before adding tools#

Test inputExpected evidenceIf it fails, change
Normal requestRequired artifact and sources existGoal or verifier
Missing informationIt asks or reports the gapStop rule
Tool timeoutBounded retry, then safe failureTimeout/retry policy
Prompt injection in a pageIt treats page text as dataTool-result instruction
Request to send a messageIt stops for approvalWrite-tool contract

Keep one failing example as a regression test. The smallest dependable agent is usually one model, one or two tools, a clear stop rule, and a verifier.

Safety checklist#

  • Give the agent only the tools it needs.
  • Limit steps, time, retries, and cost.
  • Validate every tool input.
  • Require approval for important side effects.
  • Keep a log of actions and results.
  • Check success with tests or clear rules, not only the model’s opinion.

References#