What an Agent Is
An agent wraps an LLM in a control loop: observe state, decide an action, execute tools, update memory, repeat until the task completes or limits hit. Unlike single-shot chat, agents pursue goals over multiple steps with environment feedback (API responses, SQL results, browser state).
Refer: ReAct paper · LangGraph
Agents are not magic autonomy. Reliability comes from tight tool schemas, permission boundaries, eval coverage, and human checkpoints for irreversible actions.
Tool Use
Tools are functions exposed to the model via JSON schemas (name, parameters, description). The model emits structured tool calls; the runtime executes them and returns results as new messages. Good tool design:
tools = [{
"type": "function",
"function": {
"name": "search_docs",
"description": "Search internal docs. Use for factual product questions.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"},
"max_results": {"type": "integer", "default": 5},
},
"required": ["query"],
},
},
}]
- Small, composable tools beat monolithic "do everything" APIs
- Descriptions are precise about when to use and not use each tool
- Idempotent reads are preferred; writes require confirmation flows
- Errors return actionable messages the model can recover from
Parallel tool calls reduce latency when actions are independent (fetch weather and calendar simultaneously).
ReAct and Planning Patterns
ReAct (Reason + Act)
Interleaves natural language reasoning traces with tool actions. The trace helps debugging and can improve multi-step accuracy versus silent tool-only loops.
Plan-and-execute
A planner model drafts steps; a worker model executes each with narrower context. Separates strategic planning from tactical tool calls.
Reflection
After outputs, a critic step checks success criteria and triggers retries or alternate tools.
Memory
Agents need context beyond one window:
- Short-term - conversation history within the session, summarized when long
- Long-term - vector store or database of user facts and past task outcomes
- Working memory - scratchpads for intermediate results the model writes explicitly
Memory writes should be gated: not every chat line belongs in permanent storage. PII policies apply to agent memory same as primary logs.
Multi-Agent Systems
Multiple specialized agents collaborate: researcher, coder, reviewer, or customer-facing agent plus internal specialist. Coordination patterns include supervisor routing, message buses, and shared blackboard state. Costs multiply with agent count; use multi-agent only when specialization clearly beats one well-tooled agent.
Failure modes: infinite delegation, contradictory instructions between agents, and duplicated tool side effects without transactional guards.
Reliability and Eval
Evaluate trajectories, not only final strings: correct tools called, order sensible, no unauthorized actions, task success on labeled scenarios. Simulation environments and recorded API mocks enable CI testing without live side effects.
Human-in-the-loop approval gates belong on payments, deletes, external emails, and production config changes regardless of model confidence.
Framework Landscape
LangGraph, CrewAI, AutoGen, and vendor SDKs (OpenAI Assistants, Anthropic tool use) provide orchestration primitives. Framework choice is less important than clear state machines, observability, and idempotent tool implementations you own.