AI Agents Explained: How They Actually Work
Originally published on DevToolHub.
AI agents explained in one sentence: software where an LLM decides what to do next based on the result of what it just did, in a loop, instead of following a script you wrote in advance.
What makes something an "agent"?
Anthropic draws the line clearly: a workflow is orchestrated "through predefined code paths," while an agent is a system where the LLM "dynamically directs its own processes and tool usage." Your code decides the next step in a workflow; the model decides it in an agent.
How tool calling actually works
Ollama's /api/chat shows the real shape: a tools array describes each function (name, description, parameters), and the model returns tool_calls with the function name and arguments when it wants to use one. Your code executes it and returns the real result as a new message — the model never touches your systems directly.
The loop needs a stopping condition
Observe, decide, act, feed the result back — repeat. Anthropic's own guidance: agent tasks "often terminate upon completion, but it's also common to include stopping conditions (such as a maximum number of iterations) to maintain control." Without one, the loop has no natural end.
Where MCP fits in
Tool-calling JSON handles the request format. MCP standardizes how agents discover and connect to tools they don't already know about. See best MCP servers by category and the MCP auth spec change before connecting an agent to a third-party server.
Why agents get stuck looping
A common failure: the same tool call repeated forever, because "nothing in its setup tells it that repeating an identical call is pointless." Iteration limits (LangGraph 25 steps, LangChain 15) catch this late. A no-progress guard on repeated (tool, arguments, result) tuples catches it in seconds.
Workflow or agent?
Fixed, known steps → workflow. Steps that depend on what's discovered along the way → agent. Most systems mix both.
Full article with FAQ: devtoolhub.com/ai-agents-explained