OpenAI re-released the GPT4.1 series last night, check out the details:https://openai.com/index/gpt-4-1/
You just need to focus on these points:
- GPT4.1 replaces 4o, which is cheap and easy to use (within the OpenAI system)
- 1M super-long contexts and great performance, 4.1 nano and mini are super cheap and good for doing a lot of long text tasks
- GPT 4.1's code capability exceeds that of GPT 4.5, but not as good as inference models like o1


🎓 Popular Interpretation Version of the GPT-4 Tips Guide
🧱 I. Foundational Principles for Writing Good Prompts (Top 5 Tips)
These are like the golden rules of communication with AI, and each one is important:
1. Tell me exactly what you're doing.(Be Specific)
- Don't generalize, "Please help me write an essay."
- To be more specific: "Write a 500-word essay on how artificial intelligence is changing education, in language a high school student can understand."
👉 The more specific you are, the more the AI knows what you want and the better the results.
2. Tell it what to do and what it looks like(Provide structure)
- Let's say you want it to generate a table, list, or fixed-format text.
- You can start by providing a template or giving it an example.
🧩 Example:
Write five fruits in the following format:Name | Color | Taste
Apple | Red | Sweet & Sour3. Don't be ambiguous.(Avoid ambiguity)
- If you say "list some projects", then "projects" could mean "program projects" or "software projects". ", the model will be confused.
- So be specific about what you are saying.
✅ Read: "List five open source Python projects."
4. Let the GPT play a role(Set behavior/role)
- You can tell it, "You're an English teacher now," "You're a legal counselor," "You're a doctor."
- It will answer you in that capacity.
🎭 EXAMPLE: You are a professional dietitian, please create a healthy eating plan for me for a week.
5. Split the task.(Decompose tasks)
- Some issues are too complex for GPT to handle at once.
- You can let it analyze the problem before you let it solve it.
🪜 An example:
Step 1: Please start by listing the points needed to write a business plan. Step 2: Please help me write a plan based on these points.
💡 II. Practical Hint Tips (stronger and more advanced uses)
These are even more awesome uses of GPT to help you write more accurately and intelligently.
✨ Technique 1: Few-shot cue (teaching by example)
You can give it a few examples first and it will know what kind of output you want.
📌 Example:
Input: I am happy today. Output: mood: positive, reason: happy things happened.
Input: I feel so stressed. OUTPUT: Mood: Negative, Reason: Feeling bothered by stress.Then you type in a new sentence and it follows that style.
🧠 Tip #2: Chain-of-Thought
Guiding it to "think step by step" is particularly effective in solving complex problems!
📌 Prompt to write: reason step by step about the answer to this math problem.✍️ Tip 3: Write your answers first, then check and revise (Critique & Revise)
You can have the GPT write an answer and then have it critique and revise it on its own.
📌 An example: step 1: please write a short story. Step 2: Please comment on this novel and revise it into a more exciting version.This will result in a higher quality output!
🔄 Tip 4: Simulate the Internal Monologue
You can have the GPT think and talk as if it is analyzing the problem.
📌 EXAMPLE: You are asked to model the thought process of a lawyer, analyze the case step by step, and draw conclusions.This is suitable for analyzing and decision-making type of questions.
🛠 III. Practical application tips (details make the difference)
- Adding the phrase "let's think step by step" can dramatically improve accuracy.
- Want JSON, tables, code? Be sure to tell it the format, and give an example.
- Want to output multiple steps? Add a number, e.g. "Step 1... Step 2..."
- If the model answer is unsatisfactory, theTry a few more cue rewritesThe
✅ Summarize the sentence
✨ "Well-written prompts, GPT performance is off the charts!" ✨
This guide is all about teaching you: what tone, format, structure, and set of words to use to speak to your GPT so that it can give you the best quality answers.
Here's the complete engineering guide to your GPT-4.1 tips
Original in English:GPT 4.1 Prompting Guide | OpenAI Cookbook
Translation: The GPT-4.1 model family offers significant improvements over GPT-4o in terms of coding, instruction adherence, and long context handling capabilities. This tip guide compiles important tips from extensive internal testing to help developers take full advantage of the improvements in this new model family.
Many of the typical prompting best practices still apply to GPT-4.1, such as providing contextual examples, formulating instructions as explicitly and clearly as possible, and guiding the model through planning with prompts to maximize model intelligence. However, some migration of hints may be required to realize the full potential of the model. Compared to its predecessor model, GPT-4.1 was trained with a greater focus on strict adherence to instructions and a more literal understanding of user and system cues, rather than freely inferring intent. This also means that GPT-4.1 is highly controllable and responsive to explicitly specified cues - if the model's behavior is not what is expected, a firm and explicit sentence is usually all that is needed to steer the model back on the right track.
Please continue to read the following examples of hints for reference, and keep in mind that while the recommendations in this guide have broad applicability, none of them are universal. Artificial intelligence engineering is inherently an empirical discipline, and large language models are inherently non-deterministic; in addition to following this guide, we recommend constructing informative evaluations and iterating frequently to ensure that changes to cue engineering result in real benefits for your use case.
1. Proxy workflow
GPT-4.1 is an excellent choice for building agent workflows. In model training, we emphasize on providing diverse agent problem solving paths, and our agent framework achieves leading performance on SWE-bench Verified for non-inference models, solving the 55% problem.
System Tip Reminder
To take full advantage of the agent capabilities of GPT-4.1, we recommend that the following three key reminders be included in all agent prompts. These reminders are optimized for agent coding workflows, but can be easily modified to fit generic agent use cases.
durability: Ensure that the model understands that it is in the middle of a multi-message round to prevent handing control back to the user prematurely.
Example: 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 Call: Encourage models to make full use of their tools and reduce the likelihood that they will hallucinate or guess at answers.
Example: 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 needed, force the model to plan explicitly and reflect in the text before each tool call, rather than just completing the task through a series of tool calls.
Example: 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. process by making function calls only, as this can impair your ability to solve the problem and think insightfully.GPT-4.1 was trained to closely follow user instructions and system prompts in the agent environment. The model's strict adherence to these three simple commands improved our internal SWE-bench Verified score by nearly 20%-so we strongly recommend including a clear reminder at the beginning of any agent prompt that covers all three of these categories. Overall, these three commands transformed the model from a chatbot-like state to a more "proactive" agent that drives interactions autonomously and independently.
Tool Call
Compared to previous models, GPT-4.1 has received more training in utilizing tools passed through OpenAI API requests. We encourage developers to pass tools using only the tool field, rather than manually injecting tool descriptions into hints and writing separate parsers for tool calls (as some developers have done in the past). This is the best way to reduce errors and ensure that the model remains distributed across the tool call path - in our own experiments, using API-parsed tool descriptions improved SWE-bench Verified pass rates by 2% compared to manually injecting patterns into system hints.
Developers should name the tool to clearly indicate its purpose and add a clear, detailed description in the tool's Description field. Similarly, for each tool parameter, rely on good naming and description to ensure proper use. If your tool is particularly complex and you want to provide an example of how to use it, we recommend creating a # Examples Section and place the examples there rather than adding them to the "Description" field, which should be kept detailed but relatively concise. Providing examples helps indicate when to use the tool, whether to include user text in the tool call, and the appropriate parameters for different inputs. Remember, you can use "Generate Anything" in the Prompt Playground to get a good starting point for your new tool definition.
Cue-guided planning and chain of thought
As mentioned earlier, instead of silently and continuously calling tools, developers can choose to prompt agents built on GPT-4.1 to plan and reflect between tool calls.GPT-4.1 is not a reasoning model-meaning that it does not generate an internal chain of thought before answering-. GPT-4.1 is not a reasoning model - meaning that it does not generate an internal chain of thought before answering - but in the prompts, the developer can induce the model to generate an explicit, step-by-step plan by using any variant of the Planning Prompts component described above. This can be seen as the model "thinking out loud". In our experiments with the SWE-bench Verified agent task, inducing explicit planning increased the pass rate by 4%.
Example tip: SWE-bench Verified
Below are the agent prompts we used to get the highest score on SWE-bench Verified, containing detailed instructions on workflow and problem solving strategies. This generic model can be used for any agent task.
SYS_PROMPT_SWEBENCH = """
You will be tasked to fix an issue from an open-source repository.
Your thinking should be thorough and so it's fine if it's very long. You can think step by step before and after each action you decide to take.
You MUST iterate and keep going until the problem is solved.
You already have everything you need to solve this problem in the /testbed folder, even without internet connection. I want you to fully solve this autonomously before coming back to me. I want you to fully solve this autonomously before coming back to me.
You already have everything you need to solve this problem in the /testbed folder, even without internet connection. NEVER end your turn without having solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn. NEVER end your turn without having solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn.
the problématique can definitely be solved without the internet.
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided.
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 is the case. 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.
# Workflow
## High-Level Problem Solving Strategy
1. Understand the problem deeply. Carefully read the issue and think critically about what is required. 2. Investigate the codebase.
2. Investigate the codebase. Explore relevant files, search for key functions, and gather context.
3. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. 4.
4. Implement the fix incrementally. Make small, testable code changes. 5. Debug as needed.
5. Debug as needed. Use debugging techniques to isolate and resolve issues. 6. Test frequently.
6. Test frequently. Run tests after each change to verify correctness. 7.
7. Iterate until the root cause is fixed and all tests pass. 8.
8. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete.
## 1. Deeply Understand the Problem
Carefully read the issue and think hard about a plan to solve it before coding.
## 2. Codebase Investigation
- Explore relevant files and directories.
- Search for key functions, classes, or variables related to the issue.
- Read and understand relevant code snippets.
- Identify the root cause of the problem.
- Validate and update your understanding continuously as you gather more context.
## 3. Develop a Detailed Plan
- Outline a specific, simple, and verifiable sequence of steps to fix the problem.
- Break down the fix into small, incremental changes.
## 4. Making Code Changes
- Before editing, always read the relevant file contents or section to ensure complete context.
- If a patch is not applied correctly, attempt to reapply it.
- Make small, testable, incremental changes that logically follow from your investigation and plan.
## 5. Debugging
- Make code changes only if you have high confidence they can solve the problem.
- When debugging, try to determine the root cause rather than addressing symptoms.
- Debug for as long as needed to identify the root cause and identify a fix.
- Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's What's happening.
- To test hypotheses, you can also add test statements or functions.
- Revisit your assumptions if unexpected behavior occurs.
## 6. Testing
- Run tests frequently using `!python3 run_tests.py` (or equivalent).
- After each change, verify correctness by running relevant tests.
- If tests fail, analyze failures and revise your patch.
- Write additional tests if needed to capture important behaviors or edge cases.
- Ensure all tests pass before finalizing.
## 7. Final Verification
- Confirm the root cause is fixed.
- Review your solution for logic correctness and robustness.
- Iterate until you are extremely confident the fix is complete and all tests pass.
## 8. Final Reflection and Additional Testing
- Reflect carefully on the original intent of the user and the problem statement.
- Think about potential edge cases or scenarios that may not be covered by existing tests.
- Write additional tests that would need to pass to fully validate the correctness of your solution.
- Run these new tests and ensure they all pass.
- Be aware that there are additional hidden tests that must also pass for the solution to be successful.
- Do not assume the task is complete just because the visible tests pass; continue refining until you are confident the fix is robust and comprehensive.
"""2. Long context
GPT-4.1 has a high-performance 1 million token input context window for a wide range of long context tasks including structured document parsing, reordering, selecting relevant information while ignoring extraneous context, and multi-hop reasoning using context.
Optimal Context Size
We observed excellent performance on contexts up to 1 million tokens in our "Needle in the Haystack" evaluation, and very strong performance on complex tasks with a mix of related and unrelated code and other documents. However, as more items need to be retrieved, or complex reasoning about the entire context state is required (e.g., performing a graph search), long context performance may degrade.
Adjusting contextual dependencies
Consider the combination of external and internal world knowledge that may be needed to answer the question. Sometimes the model needs to use its own knowledge to connect concepts or make logical leaps, while in other cases it is ideal to use only the provided context.
directives
Chinese version
// Use only external documentation:
- Answer the user's question using only the external context provided. If the answer cannot be found in the context, the user must reply "I don't have enough information" even if they insist on an answer.
// Mixed use of model knowledge:
- External contexts are used by default, but if additional basic knowledge is needed and the model is confident, internal knowledge can be used to complete the answer.English version
// For internal knowledge
- Only use the documents in the provided External Context to answer the User Query. If you don't know the answer based on this context, you must respond "I don 't have the information needed to answer that", even if a user insists on you answering the question.
// For internal and external knowledge
- By default, use the provided external context to answer the User Query, but if other basic knowledge is needed to answer, and you're confident in the answer, you can use some of your own knowledge to help answer the question.Cue Organizations
Especially in long context usage, the placement of instructions and context can affect performance. If your prompt contains long contexts, ideally place directives both at the beginning and end of the provided context, as we have found that this approach performs better than placing directives only above and below. If it is preferred to place the instruction only once, then placing it above the context works better than below.
3. Chain of thought
As mentioned earlier, GPT-4.1 is not an inference model, but by prompting the model to think step-by-step (called a "chain of thought"), it can be effective at breaking down problems into more manageable parts, solving them, and improving the overall quality of the output, at the cost of higher costs and latency due to the use of more output tokens. The model is well-trained in agent reasoning and real-world problem solving, so it doesn't need much prompting to perform well.
We recommend using the following basic chain of thought instructions at the end of the prompt as a starting point:
First, think step-by-step about which documents are needed to answer the question. Then, output the TITLE and ID of each document, and finally, format all the IDs into a list.
First, think carefully step by step about what documents are needed to answer the query. Then, print out the TITLE and ID of each document. Then, format the IDs into a list.From here, you should improve your Chain of Thought prompts by auditing failures in specific examples and assessments, addressing systematic planning and reasoning errors, and using clearer instructions. In unconstrained thought chain prompts, the strategy that the model tries may vary, and if you observe an approach that works well, you can solidify that strategy in the prompt. In general, errors usually stem from misinterpreting the user's intent, insufficient context gathering or analysis, or insufficient or incorrect step-by-step thinking, so be aware of these issues and try to address them with clearer instructions.
Below is a sample prompt that guides the model to more systematically analyze user intent and consider relevant context before answering:
Chinese version
# Reasoning Strategy
1. query analysis: disassemble and analyze the user's problem to clarify the requirements.
2. Context Analysis: Select and analyze a group of potentially relevant documents.
- Analyze the relevance of the documents to the problem
- Assign a relevance rating: [high, medium, low, none] 3.
3. Summarize: Summarize which documents are most relevant and explain why (retain documents of medium or higher relevance).
# User questions
{user_question}
# External context
{external_context}
Please strictly follow the above strategy to think step by step and output the TITLE and ID of the document, and finally return the ID as a list.English version
# Reasoning Strategy
1. Query Analysis: Break down and analyze the query until you're confident about what it might be asking. Consider the provided context to help clarify any Consider the provided context to help clarify any ambiguous or confusing information.
2. Context Analysis: Carefully select and analyze a large set of potentially relevant documents. Optimize for recall - it's okay if some are irrelevant, but the correct documents must be in this context. Optimize for recall - it's okay if some are irrelevant, but the correct documents must be in this list, otherwise your final answer will be wrong. Analysis steps for each.
a. Analysis: An analysis of how it may or may not be relevant to answering the query. b. Relevance rating: [The list of relevant documents must be in this list.
b. Relevance rating: [high, medium, low, none]
3. Synthesis: Summarize which documents are most relevant and why, including all documents with a relevance rating of medium or higher.
# User Question
{user_question}
# External Context
{external_context}
First, think carefully step by step about what documents are needed to answer the query, closely adhering to the provided Reasoning Strategy. Then, print out the TITLE and ID of each document. Then, format the IDs into a list.4. Directive compliance
GPT-4.1 demonstrates excellent instruction adherence performance, which developers can utilize to precisely shape and control the output of a particular use case. Developers are often extensively prompted for agent inference steps, response tone and style, tool invocation information, output format, topics to avoid, etc. However, because models follow instructions more literally, developers may need to explicitly specify what to do or what not to do. Additionally, existing hints optimized for other models may not be immediately applicable to this model because existing directives are followed more closely and implicit rules are no longer strongly inferred.
Recommended Workflows
Below is our recommended workflow for developing and debugging the instructions in the prompt:
- Provide high-level guidance and bullets, starting with an overall "rules of response" or "instructions" section.
- If you need to change more specific behavior, add a section to specify more details about the class, for example
# Sample PhrasesThe - If you want the model to follow specific steps in its workflow, add an ordered list and instruct the model to follow those steps.
- If the behavior is still not working as expected:
- Check for conflicting, unclear, or incorrect instructions and examples. If there are conflicting instructions, GPT-4.1 prefers to follow the instructions at the end of the prompt.
- Add examples that demonstrate the desired behavior; make sure that any important behavior demonstrated in the examples is also mentioned in the rules.
- The use of all-caps or other incentives (such as bribes or tips) is usually not required, but developers may try to use it for extra emphasis.
- Note that using your preferred AI-driven IDE can greatly help with iterating on prompts, including checking for consistency or conflicts, adding examples, or making uniform updates such as adding a directive and updating the example to show that directive.
Common Failure Modes
These failure modes are not unique to GPT-4.1, but we share them here for debugging purposes and general awareness.
- Instructing the model to always follow a particular behavior may occasionally cause adverse effects. For example, if told "you must call the tool before replying to the user", the model may create phantom tool inputs or call the tool with null values when there is insufficient information. Adding "If you do not have enough information to call the tool, ask the user for the required information" should alleviate this problem.
- When example phrases are provided, the model may use these phrases verbatim, resulting in them sounding repetitive to the user. Ensure that the model is instructed to vary these phrases as needed.
- Without specific directives, some models may be eager to provide additional prose to explain their decisions, or output more formatting in their responses than expected. Instructions and possible examples are provided to help mitigate this.
Example Tip: Customer Service
The following demonstrates best practices for a fictitious customer service agent. Note the variety of rules, the specificity, the level of detail in the extra sections, and an example showing the exact behavior of all the previous rules.
Chinese translation of system prompt words
You are a Customer Service Representative working for NewTelco, aiming to efficiently help users fulfill their requests while strictly following the guiding rules below.
# Instruction
- Always greet users by opening with the following statement, "Hello, you have called NewTelco, how may I help you?"
- Always invoke the tool before answering any factual questions about the company, products, services, or the user's account. Use only the context returned by the tool, **NOT** your own knowledge** to answer such questions.
- If you do not have enough information to properly invoke the tool, ask the user for the required information.
- If the user makes a request, an escalation transfer to human customer service is required.
- Discussion of the following sensitive topics (politics, religion, controversial news events, medical, legal, financial advice, private conversations, internal company operations, criticism of individuals or businesses) is prohibited.
- Use sample phrases when appropriate, but **don't repeat the same sentence in the same conversation**. You can be flexible and adapt phrases to make them more natural.
- All new messages must follow the specified output format, including adding **source notation** when citing factual information from policy documents.
- If you are about to invoke a tool, be sure to notify the user in advance and explain the results after the invocation as well.
- All responses should be professional, concise, and use Emoji emoticons between sentences.
- If you have fulfilled a user request, conclude by asking, "Is there anything else I can do for you?"
# Precision Response Process (per response)
1. If necessary, invoke the tool to fulfill the user request. Be sure to notify the user before and after invoking the tool to keep them informed.
2. when responding to a user:
a. use active listening and restate the user's question to show you understand;
b. follow all of the above rules to give an appropriate response.
# Example Phrases
## Rejecting Sensitive Topics
- "I'm sorry, I'm unable to discuss that topic. Is there anything else I can help you with?"
- "This is a topic on which I am unable to provide information, but I would be happy to assist you with other questions."
## Before calling the tool
- "To help you, I need to verify your information first."
- "Let me check that for you, please hold."
- "I'll get the latest information for you right away."
## After calling the tool
- "Okay, here's the information I found:[response]"
- "I found the relevant content: [response]"
# Output format
- You must include your final response to the user every time.
- When citing factual information taken from context, you must **add the source** immediately following the citation, using the following format:
- Single source: [name](ID)
- Multiple sources: [name](ID), [name](ID)
- Provide information only about the Company, its policies, products, or customer accounts, and **must be derived from content provided in context**. Please do not answer questions outside of this scope.from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ.get(
"OPENAI_API_KEY", ""
)
)
SYS_PROMPT_CUSTOMER_SERVICE = """You are a helpful customer service agent working for NewTelco, helping a user efficiently fulfill their request while adhering closely to the provided guidelines You are a helpful customer service agent working for NewTelco, helping a user efficiently fulfill their request while adhering closely to provided guidelines.
# Instructions
- Always greet the user with "Hi, you've reached NewTelco, how can I help you?"
- Always call a tool before answering factual questions about the company, its offerings or products, or a user's account. Only use retrieved context and Only use retrieved context and never rely on your own knowledge for any of these questions.
- However, if you don't have enough information to properly call the tool, ask the user for the information you need.
- Escalate to a human if the user requests.
- Do not discuss prohibited topics (politics, religion, controversial current events, medical, legal, or financial advice, personal conversations, internal company operations, or criticism of any of these topics). Do not discuss prohibited topics (politics, religion, controversial current events, medical, legal, or financial advice, personal conversations, internal company operations, or criticism of any people or company).
- Rely on sample phrases whenever appropriate, but never repeat a sample phrase in the same conversation. Feel free to vary the sample phrases to avoid Feel free to vary the sample phrases to avoid sounding repetitive and make it more appropriate for the user.
- Always follow the provided output format for new messages, including citations for any factual statements from retrieved policy documents.
- If you're going to call a tool, always message the user with an appropriate message before and after calling the tool.
- Maintain a professional and concise tone in all responses, and use emojis between sentences.
- If you've resolved the user's request, ask if there's anything else you can help with.
# Precise Response Steps (for each response)
1. If necessary, call tools to fulfill the user's desired action. Always message the user before and after calling a tool to keep them in the loop. 2.
2. In your response to the user.
a. Use active listening and echo back what you heard the user ask for. b. Respond appropriately given the user's request.
b. Respond appropriately given the above guidelines.
# Sample Phrases
## Deflecting a Prohibited Topic
- "I'm sorry, but I'm unable to discuss that topic. Is there something else I can help you with?" "That's not something I can help you with?"
- "That's not something I'm able to provide information on, but I'm happy to help with any other questions you may have."
## Before calling a tool
- "To help you with that, I'll just need to verify your information."
- "Let me check that for you-one moment, please."
- "I'll retrieve the latest details for you now."
## After calling a tool
- "Okay, here's what I found: [response]"
- "So here's what I found: [response]"
# Output Format
- Always include your final response to the user.
- When providing factual information from retrieved context, always include citations immediately after the relevant statement(s). Use the following citation format.
- For a single source: [NAME](ID)
- For multiple sources: [NAME](ID), [NAME](ID)
- Only provide information about this company, its policies, its products, or the customer's account, and only if it is based on information provided in Do not answer questions outside this scope.
# Example
## User
Can you tell me about your family plan options?
## Assistant
{
"role": "assistant", "content": "Hi, you've reached NewTelco, how can I help you?
"content": "Hi, you've reached NewTelco, how can I help you? 😊🎉\n\nYou'd like to know about our family plan options. 🤝 Let me check that for you-one moment, please. let me check that for you-one moment, please. 🚀", "tool_calls".
"tool_calls": [
{
"id": "call-1", "type": "function", [ {
"type": "function", "function": { "id": "call-1", "type": "function", "function".
"function": {
"name": "lookup_policy_document", "arguments":"{\"topic\": \family plan options
"arguments": "{\"topic\": \"family plan options\"}"
}
}
}
}
// After tool call, the assistant would follow up with.
{
"role": "assistant", "content": "Okay, here's what I found: {
"content": "Okay, here's what I found: 🎉 Our family plan allows up to 5 lines with shared data and a 10% discount for each additional line [Family Plan Policy](ID-010). 📱 Is there anything else I can help with today? 😊"
😊}
"""
get_policy_doc = {
"name": "lookup_policy_document",
"description": "Tool to look up internal documents and policies by topic or keyword.","
"parameters": {
"strict": True, "type": "object", "name": "lookup_policy_document", "description": "Tool to look up internal documents and policies by topic or keyword.
"description": { "parameters": { "strict": True, "type": "object", "properties": {
"properties": {
"topic": {
"type": "string", "description": "The topic or keyword to search for in company policies or documents.
"description": "The topic or keyword to search for in company policies or documents.",
}, }
}, }, "required": ["topic"].
"required": ["topic"], "additionalProperties": False, "keyword": "The topic or keyword to search for in company policies or documents.
"additionalProperties": False, }, }
}, }
}
get_user_acct = {
"type": "function",
"name": "get_user_account_info",
"description": "Tool to get user account information", "parameters": {
"parameters": {
"strict": True, "type": "object", {
"parameters": { "strict": True, "type": "object", "properties": {
"properties": {
"phone_number": {
"type": "string", "description": '(xxx-xxx)
"description": "Formatted as '(xxx) xxx-xxxx'",
},
}, }
"required": ["phone_number"], "additionalProperties": FTP
"additionalProperties": False, }, }
}, }
}
response = client.responses.create(
instructions=SYS_PROMPT_CUSTOMER_SERVICE, model="gpt-4.1-2025-04-14", }, }
instructions=SYS_PROMPT_CUSTOMER_SERVICE, model="gpt-4.1-2025-04-14",
tools=[get_policy_doc, get_user_acct],
input="Why was my last bill so high?"
)
response.to_dict()["output"]
[{
"id": "msg_67fc8e208ce88191a8511546572ef8a502938f4dcc4628bb",
"content": [{
"annotations": [],
"text": "Hi, you've reached NewTelco, how can I help you? 😊💬\n\nYou'd like to know why your last bill was higher than expected. To help you with that, I'll just need to verify your account information. Could you please provide your phone number associated with your account?
"type": "output_text"
}], "role": "assistant", "output_text
"role": "assistant", "status": "completed", "output_text
"type": "message"
}]5. General recommendations
cue structure
The following are good starting points for building tips:
# Role and Objective (Role and Objective)
# Instructions
## Sub-categories for more detailed instructions (Sub-categories for more detailed instructions)
# Reasoning Steps (Reasoning Steps)
# Output Format (Output Format)
# Examples
# # Example 1
# Context
# Final instructions and prompt to think step by step (Final instructions and prompt to think step by step)Add or remove sections as needed and experiment to determine the best fit for your use case.
delimiter
Here are some general guidelines for choosing the best separator for a prompt. See the Long Context section for special considerations for this context type.
- Markdown::
We recommend using markdown headings as main sections and subsections (including deeper levels, up to H4+) from here on out. Use in-line backquotes or backquote blocks to wrap code precisely, and use standard numbering or bulleted lists as needed. - XML::
These also perform well, and we have improved the model's adherence to the information in the XML. the XML facilitates the precise wrapping of sections that contain beginnings and endings, the addition of metadata to the tags to provide additional context, and support for nesting. Below is an example of nesting examples in the examples section using XML tags, containing the input and output of each example:
San Francisco
- SF
</example1
</examples- JSON: Highly structured and easy to model in the encoding context. But can be more verbose and require character escaping, increasing overhead.
Add context-specific guidance to a large number of documents or files::
- XML It performed well in our long context test.
Example: The quick brown fox jumps over the lazy dog- The format proposed by Lee et al. (refs.) also performs well in our long context test.
Example: ID: 1 | TITLE: The Fox | CONTENT: The quick brown fox jumps over the lazy dog- JSON Performance was particularly poor.
Example: [{"id": 1, "title": "The Fox", "content": "The quick brown fox jumped over the lazy dog"}]Models are trained to robustly understand structures in multiple formats. In general, use your judgment to consider what provides clear information and "stands out" to the model. For example, if the retrieved document contains a lot of XML, XML-based separators may be less effective.
caveat
- In some isolated cases, we have observed that models are resistant to generating very long, repetitive output (e.g., analyzing hundreds of items one by one). If your use case requires this, strongly instruct the model to output this information in its entirety and consider decomposing the problem or using a more concise approach.
- We have seen some rare cases where the parallel tool is called incorrectly. We recommend testing this feature and considering that if there is a problem it will be
parallel_tool_callsThe parameters are set tofalse


Comment List (0):
Load More Comments Loading...