What is an AI Agent?
While standard LLM applications are reactive (answering user questions), AI Agents are active. An agent is given a high-level goal, access to a set of tools, and the autonomy to plan, execute, and verify its own actions to accomplish the goal.
The Agent Loop: Plan, Act, Observe
AI agents operate in a continuous loop:
- Plan: The agent decides what action to take next based on the user’s prompt.
- Act: The agent invokes a tool (e.g., executing a SQL query or calling a web search API).
- Observe: The agent reviews the tool’s output and determines if the task is complete. If not, it plans the next step.
# Simple agent tool definition using Python
class WebSearchTool(BaseTool):
name = "web_search"
description = "Searches the web for current information."
def _run(self, query: str) -> str:
return search_search_engine(query)