https://cookbook.openai.com/examples/gpt4-1_prompting_guide
- Role and objective: Tell ChatGPT who it should act as and what it's trying to accomplish
- Instructions: Provide specific guidelines for the task
- Reasoning steps: Indicate how you want it to approach the problem
- Output format: Specify exactly how you want the response structured
- Examples: Show samples of what you expect
- Context: Provide necessary background information
- Final instructions: Include any last reminders or criteria
Seperate sections with xml style like this
<examples>
<example1 type="Abbreviate">
<input>San Francisco</input>
<output>- SF</output>
</example1>
</examples>
- Persistence: this ensures the model understands it is entering a multi-message turn, and prevents it from prematurely yielding control back to the user. Our example is the following:
You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved.
- Tool-calling: this encourages the model to make full use of its tools, and reduces its likelihood of hallucinating or guessing an answer. Our example is the following:
If you are not sure about file content or codebase structure pertaining to the user’s request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
- Planning [optional]: if desired, this ensures the model explicitly plans and reflects upon each tool call in text, instead of completing the task by chaining together a series of only tool calls. Our example is the following:
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
There are two types of knowledge within GPT
- internal context: generally from training or fine-tuning
- external context: what you pass with the prompt
GPT 4.1 has a massive 1M token window, but with large context windows comes bigger issues making sure your instructions are followed.
OpenAI have suggested putting the instructions at the beginning and end if using large contexts.