Early generative AI was passive: you send a prompt, the model returns text, and a human decides what to do next. That is useful for drafting, but it cannot run a business workflow on its own. The next step is the autonomous agent: a system that can plan, check its own progress and carry out a multi-step goal with little human intervention.
In plain terms: A chatbot is a colleague who answers your question and then waits. An agent is a colleague you give a task to, who comes back when it is done, or when they are stuck.
Diagram: A passive LLM returns one text answer and a human decides the next step. An autonomous agent takes a goal and plans, acts, checks the result and repeats with little human intervention. That makes it useful for workflows and also riskier, so guardrails matter. See the animated version.
1. The core agentic loop
An agent runs a repeating cycle, borrowed from classic control systems.
- Perceive: take in the goal, the current state and any context.
- Plan: break an abstract goal, such as "audit this quarter's server error logs and flag failing optics", into an ordered list of concrete tasks.
- Act: pick a capability and use it: call an API, run a database query, read a file.
- Reflect: compare the result with the goal. If something went wrong, adjust and try again.
Diagram: An agent loops through four stages: perceive the goal and context, plan the tasks, act by calling a tool, and reflect on the result. It repeats until the goal is met or a limit such as a step budget is reached. See the animated version.
Reflection is what makes an agent more than a script. If a query returns no rows, the agent can notice why, correct its approach and run it again. In practice you always cap the number of steps and the cost, because an agent that keeps retrying can loop forever.
Diagram: After an action the agent observes the result. When a query returns no rows it reflects, notices the wrong column name, corrects the query and tries again. The example is illustrative, and a step limit prevents endless retries. See the animated version.
2. Memory: short-term and long-term
- Working memory is the context window: the current plan, intermediate values and recent tool outputs. It is fast but limited, and it disappears when the run ends.
- Episodic memory is a record of past runs kept in a vector database. When the agent meets a similar problem, it can retrieve how it solved a related one before.
Diagram: Working memory is the context window holding the current plan, state and recent tool outputs. Episodic memory stores past runs in a vector database so an agent can recall how it fixed a similar problem before. See the animated version.
Here is the loop in a few lines of Python. The llm and tools pieces are placeholders for your model call and your real functions, so treat this as the shape of an agent, not a finished one.
MAX_STEPS = 8 # a hard stop so the loop cannot run forever
def run_agent(goal: str) -> str:
history = [f"Goal: {goal}"]
for step in range(MAX_STEPS):
# Plan + act: the model chooses the next tool call, or says it is done
decision = llm("\n".join(history)) # e.g. {"tool": "run_sql", "args": {...}} or {"done": "..."}
if "done" in decision:
return decision["done"]
result = tools[decision["tool"]](**decision["args"]) # act
# Observe + reflect: put the result back so the model can adjust
history.append(f"Called {decision['tool']} -> {result}")
return "Stopped: step limit reached. A human should review."
Turning a language model into an agent shifts AI from an assistant into something that executes. That power is why the next lessons are about tools, teams of agents, testing and safety.
Coming Up Next
Day 23: Tool use and function calling: connecting LLMs to APIs, databases and shells.
AIAgents #AutonomousAI #EnterpriseAutomation #AgenticWorkflows #SoftwareEngineering
Originally published at https://sureshpallapothu.in/blog/day-22-autonomous-agents, where this post includes animated diagrams.
Top comments (0)