Instructions
High-quality instructions are essential for any LLM-powered app, but especially critical for agents.
Clear instructions reduce ambiguity and improve agent decision-making, resulting in smoother
workflow execution and fewer errors.
Best practices for agent instructions
| Use existing documents | When creating routines, use existing operating procedures, support scripts, or policy documents to create LLM-friendly routines. In customer service for example, routines can roughly map to individual articles in your knowledge base. |
|---|---|
| Prompt agents to break down tasks | Providing smaller, clearer steps from dense resources helps minimize ambiguity and helps the model better follow instructions. |
| Define clear actions | Make sure every step in your routine corresponds to a specific action or output. For example, a step might instruct the agent to ask the user for their order number or to call an API to retrieve account details. Being explicit about the action (and even the wording of a user-facing message) leaves less room for errors in interpretation. |
| Capture edge cases | Real-world interactions often create decision points such as how to proceed when a user provides incomplete information or asks an unexpected question. A robust routine anticipates common variations and includes instructions on how to handle them with conditional steps or branches such as an alternative step if a required piece of info is missing. |
You can use advanced models, like Claude Opus, Gemini Pro or GPT high, to automatically generate instructions from existing documents. Here’s a sample prompt illustrating this approach:
You are an expert in writing instructions for an LLM agent. Convert the following help center document into a clear set of instructions, written in a numbered list. The document will be a policy followed by an LLM. Ensure that there is no ambiguity, and that the instructions are written as directions for an agent. The help center document to convert is the following
{{help_center_doc}}