What is AI Agent
Translation in Progress
This page is being translated. Content below is a placeholder.
Definition
An AI Agent is not just an LLM (Large Language Model), but a system that can autonomously complete tasks.
Core formula:
Agent = LLM + Tools + Loop- LLM: The "brain" for reasoning and decision-making
- Tools: Capabilities like reading files, executing commands, web search
- Loop: Iteratively call LLM until task completion
Agent vs Chatbot
| Feature | Chatbot | Agent |
|---|---|---|
| Interaction | Q&A | Task execution |
| Capabilities | Text generation only | Use tools |
| Autonomy | Requires each instruction | Can plan and execute |
| State | Stateless or simple context | Complex state management |
Agent Capabilities
What can an Agent do?
- File operations: Read, write, edit code
- Command execution: Run shell commands
- Web interaction: Search, fetch pages
- Complex tasks: Multi-step reasoning and execution
Example: File Modification Task
User: "Fix the bug in src/utils.ts line 42"
Agent thinking:
1. Read src/utils.ts → understand code
2. Locate line 42 → identify issue
3. Decide fix → generate patch
4. Edit file → apply changes
5. Verify → check resultHow gemini-cli Implements Agents
gemini-cli's Agent implementation is in packages/core/src/core/client.ts:
typescript
// Simplified structure
class GeminiClient {
// Main loop
async run(userMessage: string) {
while (true) {
// 1. Send to LLM
const response = await this.chat.send(message)
// 2. Check for tool calls
if (response.hasToolCall()) {
// 3. Execute tool
const result = await this.executeTool(response.toolCall)
// 4. Feed result back to LLM
message = result
} else {
// 5. Done
return response.text()
}
}
}
}Summary
- Agent = LLM + Tools + Loop
- Differs from chatbots by having tools and autonomy
- Core is the "think → act → observe" loop
Next
Learn more about the pattern behind Agent reasoning: ReAct Pattern →