Each turn has four events: read the state, choose an action, run the tool, record the result. The loop repeats until a stopping rule fires.
The result of step N is part of the input to step N+1. That feedback lets the loop change course after a surprising tool result.
Event | Reads | Writes |
|---|---|---|
Read | Goal, history, past tool results. | Nothing. |
Choose | The full current state. | One action: a tool call or stop. |
Execute | The chosen action and its inputs. | A tool result. |
Record | The tool result. | The result appended to state. |
Every loop carries a maximum step count. The count guarantees termination even when the goal stays out of reach.
Token counts below are stated example parameters. Real counts are approximate and tokenizer-dependent.
stated example: start state 500 tokens, each step appends about 300 tokens of tool result
full budget of 8 steps: 500 + 8 x 300 = 500 + 2400 = 2900 tokens
early stop at step 5: 500 + 5 x 300 = 500 + 1500 = 2000 tokens
unused budget costs nothing: steps never taken append nothingThe step budget. The budget ends the loop when the goal is not reached first.
The next read-and-choose pass. Step 3 sees the updated state and picks a different action.