Agent will not terminate, it keeps re-reading the same three files until it hits the cap??
Hello everyone. I have a small research agent with three tools, list_files, read_file and write_note, and the task is only to summarise a folder into one note, but it will not finish, it reads a file, then it lists the folder again, then it reads the same file a second time, and this goes around until it hits my iteration cap at 25 and I kill it, and by then it has produced nothing at all. I have added a line saying stop once you have read every file once, and it agrees with the line in its reasoning, it will write "I have now read all files" and then call list_files immediately after, so the instruction is being read but nothing is acting on it?? My thinking is that the tool results are being summarised somewhere in the middle of the context window and the model can no longer see that the read already happened, so it has lost the record of its own work and it is starting again from what it can still see. Kindly tell me if there is a wording that makes a stop condition stick, I have tried three versions and the third one made things worse, that one stopped after a single file and wrote the note anyway. I will revert with whatever I find. Thank you all π
Not run against a model yet
0 works Β· 0 fails
Times copied by users
Problem Instructions
A stop condition the agent will act on and not only agree with, so the folder gets summarised into one note and the loop ends by itself. At the moment it says it has read every file and then calls list_files again.
- β’The run finishes on its own, comfortably under the 25 iteration cap, with the note written.
- β’Every file is read once and none of them twice, and it does not stop after the first one the way my third attempt did.
π Best Current Solution
Xander π | prompt systems has the most upvoted solution, at 2.