Learning objectives
By the end of this module, you should be able to:
- Identify goal, model, instructions, tools and state.
- Trace the observe → decide → act → observe loop.
- Explain why stop conditions and execution boundaries matter.
The five-part mental model
The goal defines success. Instructions constrain behaviour. The model proposes decisions. Tools provide bounded capabilities. State carries the facts needed across steps.
The agent loop is a feedback loop
After a tool runs, its result must become an observation for the next decision. Without that feedback, the application cannot adapt to what actually happened.
Decision and execution are different responsibilities
A model can propose an action, but the application should mediate execution. This separation is where validation, authorization, approval, timeouts and audit controls can be enforced.
Loops need boundaries
Production agents need maximum turns, timeouts, budgets and explicit stop conditions. Otherwise a harmless prototype can become an infinite or expensive loop.
Worked examples
Minimal agent loop
while not finished:
observation = observe(state)
decision = decide(observation)
if decision.kind == "tool":
result = execute_allowed_tool(decision)
state.add(result)
else:
return decision.answer
- The model proposes; the application executes.
- State changes after observations.
- A stop condition bounds the loop.
Disk investigation
Goal: Is this host low on disk?
→ choose get_disk_usage
→ observe 87% used
→ answer with evidence
- The tool result changes the final decision.
- One bounded read-only tool is enough for this example.
Try it · core lab · account-free
Trace observe → decide → act
Goal: See an agent loop execute without depending on an external model.
Before you start
- Python 3 only. The lab uses a deterministic decision fixture so you can focus on control flow.
STEP 1Run the simulation
python3 public/labs/agentic-ai/02_observe_decide_act.py
STEP 2Read each turn
Identify the observation, the decision and the action.
STEP 3Change the fixture threshold
Modify the disk percentage and predict the final answer before rerunning.
Verify
- The loop terminates successfully.
- You can point to where a tool result becomes state for the next turn.
Expected outcome
- The first turn chooses a disk tool.
- The second turn answers using the observed disk value.
Break / fix · diagnose
- If the loop repeats forever, inspect the condition that marks the task finished.
- If the answer ignores the disk value, verify that the observation includes the tool result.
Production viewFrameworks differ, but reliable agent runtimes still need bounded loops, state transitions, execution mediation and stop conditions.
Avoid these traps
Common mistakes
- Learning framework syntax before understanding the loop.
- Letting model output execute directly without a control boundary.
- Omitting a maximum-turn or stop condition.
Knowledge check
Explain the control decision, not just the vocabulary.
Open every answer only after committing to your own answer. Opening all four answers records knowledge-check activity in My Learning.
1What does the observe step do?
Adds execution results back into the decision context — Observations let the next decision react to what actually happened.
2What prevents an agent loop from continuing forever?
Explicit stop conditions and bounded turns — Production loops require explicit bounds.
3Which item describes what success means?
Goal — The goal defines the desired outcome.
4Why separate decision from execution?
So the application can validate and control actions before executing them — The application must mediate model-proposed actions.