PM-301e · Module 2

Action-Observation-Reflection

5 min read

The core agentic loop has three phases: Action (invoke a tool or generate output), Observation (receive the result), and Reflection (assess the result against the goal before the next action). Without the reflection phase, agents accumulate errors — each action is taken from a stale understanding of the world, without incorporating what was just learned.

  1. Action Phase The model generates a tool invocation or produces output. Prompt requirements: clear task goal, available tools with precise descriptions, current state (what has been done, what is known). The action must be the next step toward the goal, not a repetition of a previous action.
  2. Observation Phase The tool result is returned and injected into the context. The model receives it as a tool result block. No prompting required here — the observation is automatic in the API flow. What matters: the result must be in a format the model can interpret and act on. Opaque tool results produce poor subsequent actions.
  3. Reflection Phase Before the next action, the model assesses: did the last action achieve its goal, what is the current state, what is the next step, are there any errors to address? Prompt this explicitly: "After each tool call, assess: (1) did the result achieve the intended goal, (2) what is the updated state, (3) what is the next action." Without explicit reflection prompting, models often skip this step.
# System prompt instruction for action-observation-reflection

After each tool call, before your next action:
REFLECT:
- Result assessment: Did the tool call succeed? Was the result what I expected?
- State update: What do I now know that I didn't know before?
- Goal progress: Am I closer to the goal? By how much?
- Next action: What is the specific next step based on the current state?
- Error check: Is there anything in the result that signals a problem I need to address before proceeding?

Only proceed to the next action after completing this reflection.
If the result signals an error, address the error before continuing.
If the result is insufficient to proceed, state what additional information is needed.