Writing instructions
Instructions are the foundation of your agent’s behavior, determining how it interacts with users and handles different scenarios. There are two types of instructions: global instructions that apply throughout the conversation, and state-specific instructions that guide the agent’s behavior in particular states.
Global instructions
Global instructions define your agent’s core personality, behavior, and universal guidelines that apply throughout the conversation. These instructions are pinned and always active, regardless of the current state.
Example global instructions
Keep global instructions concise and focused on universal behaviors. State-specific behaviors should be handled in their respective states.
State instructions
State instructions guide your agent’s behavior within specific conversation states. Each state represents a distinct phase or purpose in the conversation.
Although not binding, aim for 200-600 words or 5-15 bullet points per state instruction as a healthy range. The focus is on well-written, clear instructions.
State instructions structure
For each state, consider including these sections for clarity:
Key elements to include
Variables
Specify which variables can be accessed within the state. For more information on how to use variables, see.
Transition conditions
Define conditions for transitioning to other states.
Tools
Specify which tools the agent can use and how to use them in this state.
Formatting tips
Use bullet points within state instructions to aid in planning and ensure all necessary information is collected sequentially.
Use indentation (tabs) for sub-instructions to show hierarchy and make instructions easier to read. You can use sub-bullet points for deeper levels.
Here’s a sample structure showing how to format your state instructions with proper sections and indentation: