A Common-Sense Guide to AI Engineering: Overriding tool_calls in Agent Loop (page 179)

hi, Jay

The last statement in the if block in the for loop overrides the tool_calls created outside the while loop. Is that the intended purpose, as that would cut short iterating through the “original” tool_calls if/when the response includes additional function_calls? I thought appending would be more appropriate.

Great catch, thank you! Fortunately, this issue is fixed in the refactored version of the agent loop going forward (such as on page 184). But for this first presentation of the logic flow, you’re correct, and I’ll fix this in a future edition. Thank you so much for submitting this.