Commit 60aad5a
Fix Lab 02 (Python): reset input_list per turn and resolve tool calls in conversation
The chat loop created input_list once, before the loop, and never cleared it.
After the first turn that called a tool, every later turn re-sent function call
outputs that had already been handled, and always fired the follow-up request --
so a turn with no tool call had its answer silently overwritten by a re-summary
of the previous turn's tool data.
The follow-up request also used previous_response_id without conversation, so
the agent's answers after tool calls were never saved to the conversation and
the function calls were left unresolved in conversation state. Attaching the
outputs to the conversation instead resolves them and stores the answer, and
matches the pattern already used in the consolidated A4 lab.
- Move the input_list comment inside the chat loop so the list is created per turn
- Send function call outputs with conversation= instead of previous_response_id
- Drop the duplicate FunctionTool import from the Add references snippet
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent d227890 commit 60aad5a
2 files changed
Lines changed: 8 additions & 5 deletions
File tree
- Instructions/Exercises
- Labfiles/02-agent-custom-tools/Python
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
| |||
312 | 311 | | |
313 | 312 | | |
314 | 313 | | |
| 314 | + | |
| 315 | + | |
315 | 316 | | |
316 | 317 | | |
317 | 318 | | |
| |||
375 | 376 | | |
376 | 377 | | |
377 | 378 | | |
| 379 | + | |
378 | 380 | | |
379 | | - | |
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
| |||
385 | 386 | | |
386 | 387 | | |
387 | 388 | | |
| 389 | + | |
| 390 | + | |
388 | 391 | | |
389 | 392 | | |
390 | 393 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments