← Table of Contents · Page 98 of 868

THE CORE AGENT LOOP

Part 3 of 12

A SKELETON OF THE LOOP IN CODE Here is the loop written as simple pseudocode. Pseudocode means a plain-language sketch of code that shows the idea without following the strict rules of any real programming language. The sketch is shown as indented lines. start with the goal and an empty history repeat: ask the model what to do next, giving it the history if the model says it is finished: return the final answer otherwise: run the tool the model asked for add the tool result to the history if we have repeated too many times: stop and report what we have Notice the last two lines. One line checks whether the model says it is done. The other line checks whether we have looped too many times. Those two lines are the heart of this chapter, and we will return to them.
Advertisement
Read Aloud:
0:00 / 0:00