Agents

AI Agent

Tác nhân AI (AI Agent)

An LLM-powered system that autonomously plans and executes multi-step tasks by calling tools, browsing the web, writing code, or taking actions in external systems.

An AI agent is more than a chatbot. It's a system that perceives its environment, forms a plan, takes actions (often by calling tools), observes results, and iterates — all autonomously, toward a goal.

**Core components of an agent**

1. *LLM (the brain)*: Decides what to do next given the current state and goal. 2. *Tools*: Callable functions — web search, code execution, file read/write, API calls, database queries. 3. *Memory*: Short-term (context window) and sometimes long-term (vector database of past interactions). 4. *Orchestration loop*: The cycle of plan → act → observe → plan again.

**Agent vs chatbot**

A chatbot gives one response per user message. An agent runs a loop: after each tool call, it reads the result and decides whether to call another tool, refine the plan, or return a final answer. This can go on for many steps.

**Real examples**

- Claude Code: reads your codebase, edits files, runs tests, iterates based on errors. - Devin: autonomous software engineering — plans, writes code, debugs. - Perplexity: searches the web, synthesizes results, cites sources.

**When to use agents**

When the task has unknown steps upfront, requires multiple tools, or would benefit from iteration based on intermediate results. Not every task needs an agent — simple single-step tasks (summarize this document) are overkill for agentic frameworks.

**Pitfalls**

Agents can get stuck in loops, hallucinate tool calls, or compound errors across many steps. They're more expensive (many LLM calls per task) and harder to debug. Human-in-the-loop checkpoints are important for high-stakes actions.