- Instructions define the business logic and acceptance criteria for a task.
- Functions are the tools (such as APIs) needed to perform a task according to its instructions.
Best Practices
Clearly defining tasks is essential for configuring GenerativeAgent. GenerativeAgent acts on the tasks you ask it to perform and solves customer issues across your apps. When writing or defining tasks, keep the following practices in mind:Know where to place information
Deciding which information belongs in tasks versus in the Knowledge Base can be challenging. Use this rule of thumb:- Task instructions define procedures and courses of action for GenerativeAgent.
Example: “Flip a coin. The result of coin_flip determines whether the customer starts the game.”
- Knowledge Base articles contain information and guides on how to operate during an action.
Example: “Flipping coins must use quarters. Mark the result after the coin falls into your hand and stops moving. If the coin falls from your hand, the result is null.”For example, a task that uses the
refund_eligibility API would be:
Format Instructions
Use clear instructions for tasks. Be consistent in how you use formatting elements, such as headers or bullet/numbered lists. Use markdown for task definitions.- Use headers to organize sections within the instructions
- Use lists for clarity
Provide Resolution Steps
Enumerate the steps that GenerativeAgent needs to resolve a task. This provides a logical flow of actions that GenerativeAgent can follow to be more efficient. Just as a human agent needs to check, read, resolve, and send information to a customer, GenerativeAgent needs these steps to be clearly defined.Define Functions to Call
Functions represent the set of APIs needed alongside their instructions. GenerativeAgent invokes functions to perform the necessary actions for a task. Task instructions must specify how and when GenerativeAgent should invoke a function. Here is an example of how to reference functions in task instructions: Within the “FlightStatus” task, functions might include:trip_details_extract_with_pnr: Retrieves flight details using the customer’s PNR and last name.trip_details_pnr_emails: Handles email addresses associated with the PNR.send_itinerary_email_as_string: Sends the trip receipt or itinerary to the customer via email.
API Return Handling
Provide instructions for handling API call responses after performing a function. Use the syntax(data["APICallName"]) to reference specific data returned from an API call.
Here is an example of API Return Handling:
State Policies and Scenarios
Clearly define company policies and outline what GenerativeAgent must do in various scenarios. Stating policies ensures consistency and compliance with your organization’s standards. Remember that a good portion of policies can be taken from your Knowledge Base.Ensure Knowledge Base Resourcing
Ensure that GenerativeAgent uses your Knowledge Base either through an API or the Knowledge Base tooling in the GenerativeAgent UI. Reference Knowledge Base resources within the task so GenerativeAgent can access them during conversations. You can test GenerativeAgent’s behavior using the Previewer. Store task-related information in the Knowledge Base with metadata tags. Use metadata to ensure certain articles are only used by specific tasks. If an article and a task have the same metadata tags, GenerativeAgent will filter and only use that relevant information during a conversation.Outline Limitations
Be clear about the limitations of each task. Provide instructions for handling customer requests that go beyond a task’s limits. This helps GenerativeAgent manage customer expectations, provide alternative solutions, and switch to tasks that align with the customer’s needs.Use Conditional Templates
Use conditional templating to make parts of the task instructions conditional on reference variables determined from API responses. This ensures that only the contextually relevant task instructions are available at the right time in the conversation.Use Reference Variables
Reference variables let you store and reuse specific data returned from function responses. They are powerful tools for creating dynamic and context-aware tasks. Once a reference variable is created, you can use it to:- Conditionally make other functions available
- Set conditional logic in prompt instructions
- Compare values across different parts of your GenerativeAgent workflow
- Control function exposure based on data from previous function calls
- Toggle conditional instructions in your task’s prompt depending on returned data
- Extract and transform values without hard-coding logic into prompts or code
Create Subtasks
Some tasks are larger and more complex than others. GenerativeAgent is more efficient with cohesive and direct tasks. A good practice for complex tasks is to divide them into subtasks. For example, to process a refund for a customer, GenerativeAgent might need to:- Confirm the customer’s status
- Confirm the policies allow for the refund
- Process the refund
Call Task Switch
Sometimes GenerativeAgent needs to switch from one task to another. Be explicit about which tasks to switch to based on the context.Outline Human Support
State scenarios in which GenerativeAgent needs to escalate the issue to a human agent. This ensures GenerativeAgent’s role in your organization is clearly defined.Keep It Simple
Keep task instructions focused and concise. The more details you add to tasks, the greater the chance that essential instructions could be overlooked or diluted. If instructions are too long or complex, GenerativeAgent might not follow the most important steps precisely. We recommend not placing too much task-relevant information directly in the task. Instead, use the other tools GenerativeAgent provides, such as metadata, functions, and the Knowledge Base.We do not recommend directly uploading an internal agent-facing knowledge base to the GenerativeAgent Knowledge Base.GenerativeAgent’s Knowledge Base is meant for GenerativeAgent’s use. Task instructions better suit instructions meant for agents.