Using System Prompts
Learn how to customize agent behavior using system prompts
This guide assumes that you have completed the Quickstart.
System prompts are a powerful way to customize the behavior of your agents. They are used to provide instructions to the agent on what UI components to use, how to behave, the tone / language to use, and more.
The following is a step-by-step guide on how to add a system prompt to your agent. For the purpose of demonstration, this guide builds a Harry Potter trivia agent.
Write some rules for the agent
You can give the agent rules that it must follow. For example, you can instruct the agent to use a specific UI component for a certain type of question. Here’s a demonstration of how each rule affects the agent’s output:
Rule | Output |
---|---|
Use tables to show related information such as: - Characters and their affiliations (house, blood status, etc) - Spells and their effects | ![]() |
Use graphs to show quantitative information such as: - Comparison of spells cast by characters - Number of appearances of characters in the series | ![]() |
Use carousels to show the cast members when asked about the cast. | ![]() |
Write the system prompt
You can use the rules you’ve prepared in the previous step to write a system prompt. You can also instruct the agent to play a specific role or use a specific tone / language using this prompt.
Add the system prompt to the agent
You can add the system prompt to your message history when passing it to the SDK to ensure that it is always the first message of any conversation.
If you’ve used the quickstart template, you will just need to make the highlighted changes to start using the system prompt.
You can view the full code by expanding the following code block:
Test it out!
Test our your Harry Potter trivia agent by asking it a few questions: