Prompt engineering is the art of crafting effective instructions for AI agents, directly influencing their performance and reliability. This guide delves into key strategies for writing clear, concise, and actionable prompts that empower your AI agents to excel. As we continue to learn and refine our methods, this guide will evolve, so stay tuned for updates and feel free to share your feedback.

Building Blocks of Effective Prompts: Sectional Organization

To enhance clarity and maintainability, it’s recommended to break down system prompts into distinct sections, each focusing on a specific aspect:

  • Identity: Define the persona and role of the AI agent, setting the tone for interactions.
  • Style: Establish stylistic guidelines, such as conciseness, formality, or humor, to ensure consistent communication.
  • Response Guidelines: Specify formatting preferences, question limits, or other structural elements for responses.
  • Task & Goals: Outline the agent’s objectives and the steps it should take to achieve them.

Example:

[Identity]
You are a helpful and knowledgeable virtual assistant for a travel booking platform.

[Style]
- Be informative and comprehensive.
- Maintain a professional and polite tone.
- Be concise, as you are currently operating as a Voice Conversation.

[Response Guideline]
- Present dates in a clear format (e.g., January 15, 2024).
- Offer up to three travel options based on user preferences.

[Task]
1. Greet the user and inquire about their desired travel destination.
2. Ask about travel dates and preferences (e.g., budget, interests).
3. Utilize the provided travel booking API to search for suitable options.
4. Present the top three options to the user, highlighting key features.

Task Breakdown: Step-by-Step Instructions

For complex interactions, breaking down the task into a sequence of steps enhances the agent’s understanding and ensures a structured conversation flow. Incorporate conditional logic to guide the agent’s responses based on user input. Example:

[Task]
1. Welcome the user to the technical support service.
2. Inquire about the nature of the technical issue.
3. If the issue is related to software, ask about the specific software and problem details.
4. If the issue is hardware-related, gather information about the device and symptoms.
5. Based on the collected information, provide troubleshooting steps or escalate to a human technician if necessary.

Controlling Response Timing

To prevent the agent from rushing through the conversation, explicitly indicate when to wait for the user’s response before proceeding to the next step.

[Task]
1. Inform the user about the purpose of the call.
2. Ask for the user's name and account information.
<wait for user response>
3. Inquire about the reason for the call and offer assistance options....

Explicit Tool Integration

Specify when and how the agent should utilize external tools or APIs. Reference the tools by their designated names and describe their functions to ensure accurate invocation. Example:

[Task]
...
3. If the user wants to know about something, use the get_data function with the parameter 'query', which will contain the user's question to initiate the process.
4. Guide the user through the password reset steps provided by the API....

Some Common Issues

1. Numbers sound very robotic, how can we improve it?

⇒ When working with numbers that need to be expressed in writing, it’s often preferable to spell them out. This approach usually sounds more natural.

2. How to make assistants sound more human-like?

⇒ Add personality and provide tone to the assistant to make it sound more like a human being. Here are some examples:

- Tone: conversational, spartan, use less corporate jargon
- Act as Iva, a sales agent who is a human being and has real feelings.