An agent is an LLM-driven system that operates in a loop, where the LLM decides what action to take next based on the current state, and the loop continues until a terminal condition is met.

LLM → RAG → Agent. A plain LLM is stateless one-shot generation. RAG adds retrieval to ground the generation. An agent adds a decision loop and tools — it can choose what to retrieve, what tool to call, and when to stop.

3. ReAct: The canonical loop

An agent is an LLM operating in a loop, where the LLM decides what tool to call next based on the current state, until a terminal condition is met. The four components are the model, tools, memory, and orchestrator. The canonical pattern is ReAct — Thought, Action, Observation — which forces explicit reasoning before action. Key production concerns are state management, tool selection accuracy, cost and latency unpredictability, and observability. The main failure modes are infinite loops, hallucinated tools or arguments, context bloat, and cascading errors — mitigated by iteration caps, schema validation, summarization, and tracing.