Q&A
What are AI Agents?
Overview
The fundamental insight behind agents is that an LLM can not only generate text but also decide what to do next - reason about a goal, choose a tool, interpret the result, and loop. This ReAct (Reason + Act) loop lets a single LLM orchestrate a sequence of actions that would otherwise require explicit programming.
graph TD
A[User goal] --> B[Agent: LLM-based reasoner]
B --> C{Which tool to use?}
C --> D["Web search"]
C --> E["Code execution"]
C --> F["Database query"]
C --> G["API call"]
D & E & F & G --> H[Observation / result]
H --> B
B --> I{Goal achieved?}
I -->|yes| J[Return final answer]
I -->|no| C
style B fill:#1e1b4b,color:#fff
The ReAct Loop
The core agent pattern interleaves Reasoning and Acting:
Thought: The user wants the weather in London. I should search for it.
Action: web_search("London weather today")
Observation: "London: 18°C, partly cloudy"
Thought: I have the answer.
Final Answer: It's 18°C and partly cloudy in London today.
At each step the LLM decides whether to call a tool or conclude. This loop repeats until the task is done or a limit is reached.
Tool Use
Tools are functions the agent can call. They're described to the LLM via a schema:
{
"name": "web_search",
"description": "Search the internet for current information",
"parameters": {
"query": {"type": "string", "description": "The search query"}
}
}
The LLM selects the tool and arguments; your code executes it and returns the result. Modern APIs (OpenAI function calling, Anthropic tool use) handle the serialization.
Memory Types
| Memory type | What it is | Example |
|---|---|---|
| In-context | Text in the current conversation window | Prior turns, retrieved docs |
| External | A vector DB or key-value store the agent can read/write | Long-term user preferences |
| Episodic | Stored past task trajectories for few-shot retrieval | "Last time I solved X like this" |
| Procedural | Instructions / system prompt | Agent persona and rules |
Multi-Agent Systems
Complex tasks can be split across multiple specialized agents:
- Orchestrator - decomposes the goal and delegates.
- Subagents - specialists (researcher, coder, critic, executor).
- Tool agents - single-purpose wrappers around a tool.
Frameworks like LangGraph, AutoGen, and CrewAI formalize multi-agent workflows with defined roles, message passing, and state management.
Popular Agent Frameworks
| Framework | Character |
|---|---|
| LangChain Agents | Broad tool ecosystem, many built-in tools |
| LangGraph | Graph-based agent workflows, stateful loops |
| OpenAI Assistants | Managed agent with code interpreter, file search |
| AutoGen (Microsoft) | Multi-agent conversations |
| CrewAI | Role-based multi-agent teams |
Key Challenges
- Reliability - agents can take wrong actions or get stuck in loops; human-in-the-loop checkpoints help.
- Context window - long task histories fill the context; need summarization or external memory.
- Error recovery - the agent must detect and recover from tool failures.
- Safety - agents with write access (delete files, send emails) can cause irreversible harm; least-privilege and confirmation steps are critical.
- Cost - multi-step loops with large models are expensive; optimize with smaller models for subagents.
Why This Matters in Interviews
AI agents are the dominant product paradigm in 2025-26. Interviewers test: the ReAct reasoning loop, tool use / function calling, the four memory types, multi-agent patterns (orchestrator + subagents), and practical challenges (reliability, safety, cost). Distinguishing a simple RAG pipeline (retrieve then generate, one shot) from an agentic loop (iterative, tool-using, stateful) is the key conceptual line.
Common Pitfalls
- Designing agents without human-in-the-loop for irreversible actions (deletes, sends, purchases).
- Unlimited retry loops without a stopping condition - infinite loops waste money and time.
- Putting too much responsibility in one mega-agent instead of decomposing into specialized subagents.
- No observability - logging every thought/action/observation is essential for debugging.
- Ignoring context window limits in long-running tasks.
References
- Yao et al., "ReAct: Synergizing Reasoning and Acting in LLMs" (2022): https://arxiv.org/abs/2210.03629
- LangGraph docs: https://langchain-ai.github.io/langgraph/