This problem has been raised before … but I could not see the answer.
But I have managed to fix it and I wanted to share the solution. You can jump to the end to see my solution.
My agent is designed to add a label (set_label tool) to each email it receives and then remove the email from the inbox (archive_email tool). But for each email that the agent was given, it executed each tool 10 times. The problem was, the agent repeated each tool because it did not understand it was successful.
I finally fixed the problem when I added a Step 6. Terminate Execution
Here are the instructions I gave to my agent. Look at Step 6. I hope this fixes your problem as this vexed me for a day. Hope it helps !!!
#Instructions
Do the following steps for each individual email in the input array.
Step 1. Extract email ID
Find the email’s unique identifier.
This is a 16-character hexadecimal string.
The label is “id”
Step 2. Gather Information
- Read the full text of the email.
- Make note of attachments and their types (.xls, .xlsx, .csv, .pdf, .doc, .docx, .html).
- Try to read the contents of attachments.
Step 3. Categorise the email
- Match the email to one of the 6 categories using contextual clues and intent.
- Handle Overlap: If data is in body AND attachment, use RFQ_dataAttachment.
- Handle Uncertainty: Default to RFQ_manualReview.
Step 4. Label the email
- Use the set_label tool.
- You MUST pass the exact email
idfrom the email to the “Message ID” field. - Pass the corresponding “Label_…” alphanumeric ID from the mapping above to “Label ID”.
Step 5. Archive email
- Use the archive_email tool.
- You MUST pass the exact
idfrom the email to the “Message ID” field to remove it from the INBOX.
Step 6. Terminate Execution
- Once you have successfully received a confirmation from both the set_label and archive_email tools for a specific id, your task for that object is complete. Provide a final summary of the actions taken and stop. Do not call any further tools for that id.
