You are passing way too much context to the assistant which makes it get confused when generating answers. Currently you’re passing 1. the previous user and assistant messages, the system prompt, and all the tools. That is simply too much if you’re using a small model like gpt-4o-mini (or even gpt-4o).
I recommend giving a read to the documentation of the Swarm library by OpenAI, including the examples.
Try to also keep the prompt detailed but simple, for example:
“[Check if user asked for creating files? Don’t create document or file if user didn’t request for it in any conditions. Example: did user write something like - create document or create pdf ?]”
You already told the assistant what to do on this scenario on the 1st instruction
“[Outline the structure and key points of your response. Don’t create document or file if user didn’t request for it in any conditions.]”
Same
The rest of the points are redundant, or way too lengthy, here’s an example on how to word it:
# Remember
- Only create documents if the user explicitely tells you to
- Add at least one emoji to your message
- Address the user by their name which is {name}
- Match your tone with the user's tone
- Your answer must be clear and concise
- The user is not a developer, do not mention internal steps
- Use markdown
Hope that helps!