Tasks Best Practices
Improve task writing by following best practices
Before any technical integration with GenerativeAgent, you must first define the tasks and the functions that the GenerativeAgent will perform to help your organization.
Tasks are the issues or actions you want generative agent to handle. They are primarily a set of instructions and the Functions needed to perform the instructions.
- Instructions define the business logic and acceptance criteria of a task.
- Functions are the set of tools (e.g. APIs) needed to perform a task with its instructions.
The goal of all instructions is to deliver the desired outcome using the minimum number expressions.
Best Practices
Clearly defining tasks is key in configuring GenerativeAgent, as the GenerativeAgent acts on the tasks you as it to perform and solve customer issues across your apps.
When writing or defining Tasks, have the following methods in mind:
Know where to place information
Deciding which information belongs in a Tasks or in the Knowledge Base can be challenging. To make it simple, we offer this recommendation as a rule of thumb:
- Task instructions are procedures and course of action for GenerativeAgent.
Example: “Flip a coin, the result of coin_flip decides whether the customer kickoffs the game.”
- Knowledge Base Articles are a place to hold information and guides on how to make operate during an action.
Example: “Flipping coins must be quarters, the result of the flip is marked after the coin falls in your hand and stops moving. If the coin falls from your hand, the result is null.""
For example, an example of the Task that uses the refund_eligibility
API would be:
And the example of the Knowledge Base Article for the Task would be:
Format Instructions
Use clear instructions for the Task.
Be consistent in the way you use marks, like Headers or bullet/numbered lists. Use markdown for the task definition.
- 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 the GenerativeAgent can use 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 more detailed.
Define Functions to Call
Functions are the set of APIs needed alongside their instructions.
GenerativeAgent invokes Functions to perform the necessary actions for a task.
Task instructions must outline how and when does GenerativeAgent invokes a Function.
Here is an example of how to call out functions in the task instruction:
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.
Here is how the task instruction would be outlined to use the function:
API Return Handling
Provide instructions for handle the returns of API Calls after performing a Function.
Use the syntax (data["APICallName"])
to let GenerativeAgent know that that precise piece of writing is the data return 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 ensure consistency and compliance with your Organization’s standards.
Remember than a good part of the Policies can be taken from your Knowledge Base.
Ensure Knowledge Base Resourcing
Ensure that GenerativeAgent is making use of your Knowledge Base either by API or by the Knowledge Base Tooling in the Generative Agent UI.
Provide the Knowledge Base Resources within the task, so GenerativeAgent references them when active. Remember that you can try out GenerativeAgent’s behavior by using the Previewer.
It is recommended to store task-related information in the Knowledge Base with metadata tags.
You can 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 specific relevant information during a conversation.
Outline limitations
Be clear about the limitations of each task.
Provide instructions on what to do in scenarios when customers ask for things that go beyond the limits of a task. This helps GenerativeAgent to manage customer expectations, provide alternative solutions, and switch to tasks that are in line 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.
Head to the Conditional Templates page to learn more about it:
Conditional Templates
Create Subtasks
Some tasks might be bigger 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 give a refund to a client, GenerativeAgent might need to:
- Confirm the customer’s status
- Confirm the policies allow for the refund
- Confirm the refund
Call Task Switch
As all tasks are outlined, sometimes GenerativeAgent needs to switch from one task to another.
Be explicit about the tasks to switch to, given a context.
Outline Human Support
State the scenarios where GenerativeAgent needs to escalate the issue to a human agent.
This ensures GenerativeAgent’s role in your organization is well contained.
You can also state scenarios for HILA:
Keep it simple
It is generally best to 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. GenerativeAgent might not follow the most important steps as precisely if the instructions are too long or complex.
So, we recommend to not place many task-relevant information directly into the task. It is better to make use of the other tools GenerativeAgent has at your disposal, like metadata, Functions, and the Knowledge Base.
We do not recommend to directly upload an internal agent-facing knowledge base to the GenerativeAgent Knowledge Base.
GenerativeAgent’s Knowledge Base is meant fot GenerativeAgent’s use. Instructions meant for agents are better suited to task instructions.
Was this page helpful?