What Is Agentic AI?
This page explains what agentic AI is and how an agent differs from a chatbot. It shows the agent loop, the parts of an agent, and when a fixed workflow is the better choice.
Agentic AI and the One-Shot Chatbot
An agentic system lets a model take an action, observe the result, and decide the next step. The model controls the order of steps. A chatbot answers once and stops. You send a question and you get a reply. The model does not run a tool and does not check the outcome.
The difference is the loop. A chatbot maps one input to one output. An agent maps a goal to a sequence of actions. Each action changes the state of the world. The model reads the new state before it acts again.
This loop costs more tokens and more time. The model may call a tool many times. Each call adds latency and cost. Use an agent only when the task needs a decision at each step.
The Agent Loop: Observe, Plan, Act, Observe
The loop has four steps. First, the agent observes the current state. Second, it plans the next action. Third, it acts with a tool. Fourth, it observes the result again. The loop repeats until a stop rule fires.
The plan is not fixed. The model reads the new observation and can change the plan. This is the main property of an agent. A fixed workflow cannot change its own steps.
The code below shows a small loop with a step limit. The agent reads a task list and marks one item done per step. The loop stops when the list is empty or the limit is reached.
def run_agent(state, act, stop, max_steps=5):
for step in range(max_steps):
if stop(state):
return state, step
state = act(state)
return state, max_steps
tasks = ["write", "test", "fix"]
final, used = run_agent(tasks, lambda s: s[1:], lambda s: len(s) == 0)
print(final, used)
The Parts of an Agent
An agent has five parts. The model is the decision maker. The tools are the functions the model can call. Memory holds past observations and results. A stop rule ends the loop. Guardrails limit what the agent can do.
Memory is often a list of messages. Long runs grow this list and raise the token count. A KV cache helps the model reuse past work, but the cache has a size limit. A tokenizer change can also change the token count.
Guardrails are checks around each action. A guardrail can block a shell command or limit a file write. A stop rule can be a step limit, a time limit, or a success test. Always set both.
Example: Fixing a Failing Test
A test fails in a repository. The agent runs the test and reads the error. It plans a change and edits the file. It runs the test again and observes the new result. The loop stops when the test passes or the step limit fires.
The stop rule is the passing test. The guardrail limits edits to one file. Without the guardrail, the agent could change many files and hide the real bug.
The code below shows a simple stop rule. The agent stops when the test result is true. It also stops after three attempts. The print shows the final result and the number of attempts.
def fix_loop(run_test, edit, max_tries=3):
for attempt in range(1, max_tries + 1):
if run_test():
return True, attempt
edit()
return run_test(), max_tries
print(fix_loop(lambda: False, lambda: None))
When a Fixed Workflow Is Better
A fixed workflow runs the same steps in the same order. It has no model decision at each step. This makes it cheap and easy to test. You can predict its cost in FLOPs and tokens before you run it.
Cost and reliability decide the choice. An agent may call the model ten times for one task. Each call adds cost and a chance of error. A workflow with three steps has a known cost and a known failure mode.
Use a workflow when the steps are known. Use an agent when the path depends on the result of each step. Many teams start with a workflow and add an agent only for the hard cases.
For more detail, read the tutorial pages on tool calling, prompt design, and evaluation on this site.
Common questions
Is an agent just a chatbot with tools?
No. A chatbot with tools answers once and may call a tool. An agent runs a loop and decides the next step from each result.
Why do agents fail?
Agents fail from weak stop rules, unclear tools, and long memory that confuses the model. They also fail when a step needs a fixed order that the model cannot infer.
When should I use a fixed workflow?
Use a fixed workflow when the steps are known and the cost must be low. Use an agent only when the next step depends on the result of the last step.