AI Summary Hub

AI agents

Systems that perceive, reason, and act toward goals.

Definition

An AI agent is a system that perceives its environment (e.g. user input, tool outputs), reasons (possibly with an LLM), and takes actions (e.g. calling APIs, writing code) to achieve goals. Agents often use tools and loops of thought–action–observation to solve tasks that require more than a single LLM call.

More formally: an agent is an autonomous program that talks to an AI model to perform goal-based operations using the tools and context it has, and is capable of autonomous decision-making grounded in truth. Agents bridge the gap between a one-off prototype (e.g. in AI Studio) and a scalable application: you define tools, give the agent access to them, and it decides when to call which tool and how to combine results to satisfy the user's goal.

The defining characteristic of an agent — as opposed to a simple chain or pipeline — is autonomy in deciding the next action. The agent is not following a fixed script; it uses the LLM to reason about the current state and select the most appropriate action. This makes agents powerful for open-ended tasks but also harder to predict and debug than deterministic pipelines. Multi-agent and subagent setups extend single agents with coordination patterns and hierarchical delegation.

How it works

Agent reasoning loop

Tool registration and dispatch

Typical loop: receive task → plan or reason → choose action (e.g. tool call) → observe result → repeat until done or limit. The user sends a request; the agent (backed by an LLM) produces a thought (reasoning) and a decision: either call a tool (e.g. search, API, code runner) and get an observation, or return a final answer. The observation is fed back into the agent for the next step. LLMs provide reasoning and tool selection; frameworks (LangChain, LlamaIndex, Google ADK) handle orchestration, tool registration, and message passing.

When to use / When NOT to use

ScenarioUse agentsDon't use agents
Multi-step tasks requiring multiple toolsYes — agents naturally handle complex tool chainsNo — a simple chain or pipeline is cheaper and more predictable
Tasks with unknown number of steps in advanceYes — agents decide dynamically how many steps are neededNo — if steps are fixed, use a hardcoded pipeline
Research and synthesis across many sourcesYes — agents can search, read, and integrate iterativelyNo — if the data is already structured, a batch query suffices
Safety-critical tasks without human oversightNo — agents can make unexpected decisionsYes — keep humans in the loop for high-stakes actions
Low-latency, simple, single-step responsesNo — agent overhead adds latencyYes — a direct LLM call is faster

Comparisons

ApproachAutonomyTool useStepsPredictabilityCost
Direct LLM callNoneNo1HighLow
Chain / pipelineLow (fixed flow)PossibleFixedHighLow–medium
Agent (single)High (dynamic)YesDynamicMediumMedium–high
Multi-agentVery highYesDynamic per agentLow–mediumHigh

Pros and cons

ProsCons
Flexible — can use many tools and handle open-ended tasksUnpredictable — can loop, get stuck, or take unexpected paths
Handles multi-step tasks with dynamic branchingLatency and cost from multiple LLM calls
Enables automation of complex workflowsRequires well-designed tools, schemas, and safety guardrails
Scales from prototype to production with the right frameworkDebugging requires inspecting long thought–action traces

Code examples

# Conceptual agent loop (pseudocode)
def agent_loop(task: str, tools: dict, llm) -> str:
    messages = [{"role": "user", "content": task}]
    for _ in range(10):  # max iterations
        response = llm.invoke(messages, tools=list(tools.values()))
        if response.tool_calls:
            for call in response.tool_calls:
                tool_fn = tools[call["name"]]
                result = tool_fn(**call["arguments"])
                messages.append({"role": "tool", "content": str(result)})
        else:
            return response.content  # final answer
    return "Max iterations reached."

# LangChain example with a real tool
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_community.tools import DuckDuckGoSearchRun
from langchain import hub

llm = ChatOpenAI(model="gpt-4o-mini")
tools = [DuckDuckGoSearchRun()]
prompt = hub.pull("hwchase17/openai-tools-agent")
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = executor.invoke({"input": "What are the latest developments in RAG?"})
print(result["output"])

Practical resources

Sources

See also