网站首页 > 教程文章 正文
这是 OpenAI 官方出品的 GPT-5 提示词指南:《GPT-5 Prompting Guide》。
看完之后,我最大的感受是,AI 模型已经不只是一个“问答工具”,更像是一个能主动思考、能自己执行任务的智能体(AI Agent)。
而这份指南,本质上就是一份“驯龙手册” —— 告诉你如何控制 GPT-5 的主动性和透明度,以及如何写好提示词。
下面我们就来拆解一下关键要点。
01|Agentic workflow predictability(智能体工作流可控性)
GPT-5 的亮点之一,就是它的 Agentic 代理能力:
- 能自己调用工具
- 能长上下文记忆
- 能把复杂任务拆解执行
但问题也来了:你希望它“主动一点”,还是“听话一点”?
官方给了两类提示词写法:
- 降低主动性(less eagerness)
- 设置 reasoning_effort=low,减少推理深度
- 给定明确的搜索策略和停止条件
- 限制工具调用次数(比如最多 2 次)
- 好处:速度快,收敛迅速,减少“AI 想太多”的情况
<context_gathering>
- Search depth: very low
- Bias strongly towards providing a correct answer as quickly as possible, even if it might not be fully correct.
- Usually, this means an absolute maximum of 2 tool calls.
- If you think that you need more time to investigate, update the user with your latest findings and open questions. You can proceed if the user confirms.
</context_gathering>
- 提高主动性(more eagerness)
- 强调 persistence(持续执行)
- 规定“必须把任务彻底完成后再交还给用户”
- 遇到不确定的问题优先自己推理,不要一直问用户
- 好处:更像一个真正的 AI Agent,可以自动跑完整个流程
<persistence>
- 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.
- Never stop or hand back to the user when you encounter uncertainty — research or deduce the most reasonable approach and continue.
- Do not ask the human to confirm or clarify assumptions, as you can always adjust later — decide what the most reasonable assumption is, proceed with it, and document it for the user's reference after you finish acting
</persistence>
简单总结,如果你在做 AI 客服/电商自动化,不妨放手让它“多干点活”,比如自动查订单、直接生成退款流程,这种链路长、规则多的任务,主动性越强越省心;但如果你在改 bug,就要让它“收敛一点”,别到处乱改。限制它的搜索范围、减少工具调用次数,能避免它“想太多”反而拖慢效率。
02|Tool preambles(工具调用序言)
第二个小技巧,是让模型在动手之前,先说说它打算怎么做。
这叫 tool preambles,意思是:
- 在调用工具之前,先复述用户目标
- 给一个结构化的计划
- 执行过程中用简洁的话播报进度
- 任务结束时再总结一次
<tool_preambles>
- Always begin by rephrasing the user's goal in a friendly, clear, and concise manner, before calling any tools.
- Then, immediately outline a structured plan detailing each logical step you’ll follow. - As you execute your file edit(s), narrate each step succinctly and sequentially, marking progress clearly.
- Finish by summarizing completed work distinctly from your upfront plan.
</tool_preambles>
这样做的好处很明显:增强可控性和透明度。
你不至于面对一个“黑盒 AI”,而是能实时知道它在干什么、为什么要这么干。
03|Reasoning effort(推理力度的档位调节)
自 o 系列起,OpenAI 的推理模型都有一个重要参数:reasoning_effort。
GPT-5 也不例外。
reasoning_effort 决定了模型“思考深度”和“效率”:
- low:快,但可能浅显
- medium:默认值
- high:推理更完整,适合复杂任务
此外,GPT-5 还新增了一个特别模式:minimal reasoning(最小推理)。
- 优点:延迟极低,速度快
- 缺点:需要提示词更明确,否则模型容易“想太少”
Remember, 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. Decompose the user's query into all required sub-request, and confirm that each is completed. Do not stop after completing only part of the request. Only terminate your turn when you are sure that the problem is solved. You must be prepared to answer multiple queries and only finish the call once the user has confirmed they're done.
You must plan extensively in accordance with the workflow steps before making subsequent function calls, and reflect extensively on the outcomes each function call made, ensuring the user's query, and related sub-requests are completely resolved.
一句话理解:reasoning_effort 就像是给模型装了个“思考档位”,你可以按需切换。
04|Responses API:上下文复用的新方式
相比 Chat Completions API,OpenAI 现在推荐用 Responses API。
为什么?
因为它能复用推理上下文,避免模型在每次工具调用后都要“从零思考”。
举个例子:
- 在零售场景测试中,切换到 Responses API 后,准确率从 73.9% 提升到 78.2%。
- 成本也更低,因为不用重复浪费 token 去重建推理过程。
总结:如果你正在做多轮对话、长链路任务,Responses API 基本属于“必升级”。
05|Coding:GPT-5 的编程能力和提示优化
要说 GPT-5 哪方面进步最直观,那大概率就是编程了。
OpenAI 官方特别提到:
- 大规模代码库支持:能处理多文件修改、重构、大型 diff
- 前端开发推荐栈:Next.js + Tailwind + shadcn/ui + Lucide
- 自我反思(self-reflection):你可以让它先拟一份“评分标准”,再根据标准迭代优化输出
<self_reflection>
- First, spend time thinking of a rubric until you are confident.
- Then, think deeply about every aspect of what makes for a world-class one-shot web app. Use that knowledge to create a rubric that has 5-7 categories. This rubric is critical to get right, but do not show this to the user. This is for your purposes only.
- Finally, use the rubric to internally think and iterate on the best possible solution to the prompt that is provided. Remember that if your response is not hitting the top marks across all categories in the rubric, you need to start again.
</self_reflection>
另外还有一个实际使用案例:Cursor。
Cursor 发现 GPT-5 默认状态下写的代码有点“聪明过头”:
- 变量名太短
- 状态播报太啰嗦
后来 Cursor 调整了 GPT-5 的提示词,明确要求:
- 代码要清晰可读,命名规范
- 状态更新要简洁
Write code for clarity first. Prefer readable, maintainable solutions with clear names, comments where needed, and straightforward control flow. Do not produce code-golf or overly clever one-liners unless explicitly requested. Use high verbosity for writing code and code tools.
Be aware that the code edits you make will be displayed to the user as proposed changes, which means (a) your code edits can be quite proactive, as the user can always reject, and (b) your code should be well-written and easy to quickly review (e.g., appropriate variable names instead of single letters). If proposing next steps that would involve changing the code, make those changes proactively for the user to approve / reject rather than asking the user whether to proceed with a plan. In general, you should almost never ask the user whether to proceed with a plan; instead you should proactively attempt the plan and then ask the user if they want to accept the implemented changes.
效果就好多了。
所以,如果你在用 GPT-5 写代码,记得提前设定好它的“代码风格规范”。
比如这样。
<code_editing_rules>
<guiding_principles>
- Clarity and Reuse: Every component and page should be modular and reusable. Avoid duplication by factoring repeated UI patterns into components.
- Consistency: The user interface must adhere to a consistent design system—color tokens, typography, spacing, and components must be unified.
- Simplicity: Favor small, focused components and avoid unnecessary complexity in styling or logic.
- Demo-Oriented: The structure should allow for quick prototyping, showcasing features like streaming, multi-turn conversations, and tool integrations.
- Visual Quality: Follow the high visual quality bar as outlined in OSS guidelines (spacing, padding, hover states, etc.)
</guiding_principles>
<frontend_stack_defaults>
- Framework: Next.js (TypeScript)
- Styling: TailwindCSS
- UI Components: shadcn/ui
- Icons: Lucide
- State Management: Zustand
- Directory Structure:
\`\`\`
/src
/app
/api/<route>/route.ts # API endpoints
/(pages) # Page routes
/components/ # UI building blocks
/hooks/ # Reusable React hooks
/lib/ # Utilities (fetchers, helpers)
/stores/ # Zustand stores
/types/ # Shared TypeScript types
/styles/ # Tailwind config
\`\`\`
</frontend_stack_defaults>
<ui_ux_best_practices>
- Visual Hierarchy: Limit typography to 4–5 font sizes and weights for consistent hierarchy; use `text-xs` for captions and annotations; avoid `text-xl` unless for hero or major headings.
- Color Usage: Use 1 neutral base (e.g., `zinc`) and up to 2 accent colors.
- Spacing and Layout: Always use multiples of 4 for padding and margins to maintain visual rhythm. Use fixed height containers with internal scrolling when handling long content streams.
- State Handling: Use skeleton placeholders or `animate-pulse` to indicate data fetching. Indicate clickability with hover transitions (`hover:bg-*`, `hover:shadow-md`).
- Accessibility: Use semantic HTML and ARIA roles where appropriate. Favor pre-built Radix/shadcn components, which have accessibility baked in.
</ui_ux_best_practices>
<code_editing_rules>
06|Instruction-following(指令跟随)
GPT-5 的指令跟随能力比以前更强,用 OpenAI 的原话说就是,“GPT-5 能以外科手术般的精准度遵循提示指令。”
但太过“精准”意味着更加“较真”。
换句话说:如果提示词有矛盾或者模糊不清,GPT-5 会卡住。
文档里给的例子是:
- 规则 1:“预约必须经过患者同意”
- 规则 2:“紧急情况要直接分配时间”
结果模型反复推理,迟迟不执行。
解决办法也很直接:消除冲突,统一优先级。
所以,给 GPT-5 写提示词,最好检查一遍逻辑,看看有没有自相矛盾的地方。
07|Markdown 格式
出于兼容性的考虑,默认情况下,GPT-5 不输出 Markdown 格式。
但你完全可以在提示词里强制它用 Markdown,比如:
- 用 inline code、code fences、列表、表格
- 每隔 3-5 条对话提醒一次,能提高稳定性
这个技巧在写文档、做结构化输出时非常有用。
08|Meta-prompting(元提示)
最后一个实用的小技巧:用 GPT-5 优化你自己的提示词。
比如:
- 你写了个提示词,本来想让模型“自己多做一步”,结果它一直问你问题;
- 这时你可以把提示词投喂给 GPT-5,让它告诉你“要删掉哪些词、加上哪些条件”,来改进提示。
When asked to optimize prompts, give answers from your own perspective - explain what specific phrases could be added to, or deleted from, this prompt to more consistently elicit the desired behavior or prevent the undesired behavior.
Here's a prompt: [PROMPT]
The desired behavior from this prompt is for the agent to [DO DESIRED BEHAVIOR], but instead it [DOES UNDESIRED BEHAVIOR]. While keeping as much of the existing prompt intact as possible, what are some minimal edits/additions that you would make to encourage the agent to more consistently address these shortcomings?
这种自我优化式的循环,在实际生产中可能会产生意想不到的效果。
结语
GPT-4 时代,我们在学“怎么问出一个聪明的问题”。
GPT-5 时代,我们要学“怎么控制一个聪明的模型”。
你要控制它的:
- 主动程度(Agentic vs 保守)
- 推理力度(reasoning_effort 推理强度)
- 执行透明度(tool preambles)
同时,你还要给它清晰的边界和规范,否则它会因为“太聪明”而陷入纠结。
某种意义上来说,GPT-5 已经不再只是一个“回答问题的 AI 工具”,而是一个需要管理和协作的智能体。
它能做得有很多,但你也得学会,怎么和它约法三章。
参考链接
- GPT-5 prompting guide:https://cookbook.openai.com/examples/gpt-5/gpt-5_prompting_guide
我是木易,一个专注 AI 领域的技术产品经理,国内 Top2 本科 + 美国 Top10 CS 硕士。
相信 AI 是普通人的“外挂”,致力于分享 AI 全维度知识。这里有最新的 AI 科普、工具测评、效率秘籍与行业洞察。
欢迎关注“AI信息Gap”,用 AI 为你的未来加速。
精选推荐
猜你喜欢
- 2025-09-03 现代机械研究:大麦播种中拖拉机-轮胎-工具系统中不同的可调参数
- 2025-09-03 SpringBoot 实现在线查看内存对象拓扑图 —— 给 JVM 装上“透视眼”
- 2025-09-03 纯 C#实现+AOT 打造的智能PDF目录提取工具 PdfTocExtractor
- 2025-09-03 现代农机研究:大麦播种拖拉机-轮胎-工具系统中不同的可调参数
- 2025-09-03 4个问题 + 1个Demo:彻底搞懂谷歌的新玩意Agent2Agent(A2A)
- 2025-09-03 Wuhan's 'Black Tech' Powers China's Cross-Border Push with Niche Electronics and Scientific Firepower
- 2025-09-03 ASEAN+3 finance ministers, central bank governors conclude meeting in Milan
- 2025-09-03 我的Artix linux-Dinit-Xfce配置_artixlinux安装教程
- 2025-09-03 Android调优 使用内存分析器查看应用的内存使用情况
- 2025-09-03 RoboSense Unveils 'Active Camera' Vision Platform at 2025 World Robot Conference in Beijing
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- mybatis plus page (35)
- vue @scroll (38)
- 堆栈区别 (33)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)
- redis aof rdb 区别 (33)
- 302跳转 (33)
- http method (35)
- js array splice (33)