Few-shot prompting is a powerful technique where you provide a small number of sample interactions (typically 2 to 5) to guide your agent’s behavior. This method helps the agent understand the desired output format and task requirements by learning from the given examples, thereby improving performance without writing extensive instructions.
In the Agency Swarm framework, few-shot examples are structured using the OpenAI message object format, including the role and content fields.Example: Technical Support Agent:
Copy
Ask AI
examples = [ { "role": "user", "content": "My device won't turn on.", }, { "role": "assistant", "content": "I'm sorry to hear that. Let's try some troubleshooting steps. First, please press and hold the power button for at least 10 seconds.", }, { "role": "user", "content": "I tried that, but it still won't turn on.", }, { "role": "assistant", "content": "Thank you for trying that. Please connect your device to a charger and check if any lights appear. Let me know what you observe.", }]
The optional fields attachments and metadata can be included if needed but are not required for basic examples.