jixiaxue 知识库
evidence · 2026-04-15

T1-2-gpt52-prompting-guide

/Users/shanfang/Documents/pe/jixiaxuegong/research/提示工程教程/evidence/T1-openai/T1-2-gpt52-prompting-guide.md

来源:https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-2_prompting_guide 爬取日期:2026-03-22

GPT-5.2 Prompting Guide

1. Introduction

GPT-5.2 is OpenAI’s newest flagship model designed for enterprise and agentic workloads. It delivers higher accuracy, stronger instruction following, and more disciplined execution across complex workflows. Building on GPT-5.1, this model improves token efficiency on medium-to-complex tasks, produces cleaner formatting with less unnecessary verbosity, and shows clear gains in structured reasoning, tool grounding, and multimodal understanding.

The model is especially well-suited for production agents prioritizing reliability, evaluability, and consistent behavior. It performs strongly across coding, document analysis, finance, and multi-tool agentic scenarios, often matching or exceeding leading models on task completion. While it works well out of the box for many use cases, explicit prompting remains crucial for maximizing performance in real production systems.

2. Key Behavioral Differences

Compared with GPT-5 and GPT-5.1, GPT-5.2 delivers:

3. Prompting Patterns

3.1 Controlling Verbosity and Output Shape

Provide clear and concrete length constraints, especially in enterprise and coding agents. The guide recommends:

Key principles:

3.2 Preventing Scope Drift

GPT-5.2 is stronger at structured code but may produce more code than minimal UX specs. Explicit constraints prevent unnecessary expansion:

3.3 Long-Context and Recall

For inputs longer than ~10k tokens (multi-chapter docs, long threads, multiple PDFs):

3.4 Handling Ambiguity and Hallucination Risk

When questions are ambiguous or underspecified:

For external facts that may have changed:

High-risk self-check (for legal, financial, compliance, safety contexts):

4. Compaction (Extending Effective Context)

For long-running, tool-heavy workflows exceeding the standard context window, GPT-5.2 with Reasoning supports response compaction via the /responses/compact endpoint.

When to use compaction:

Key properties:

Best practices:

Example code:

from openai import OpenAI
import json

client = OpenAI()

response = client.responses.create(
   model="gpt-5.2",
   input=[
       {
           "role": "user",
           "content": "write a very long poem about a dog.",
       },
   ]
)

output_json = [msg.model_dump() for msg in response.output]

compacted_response = client.responses.compact(
   model="gpt-5.2",
   input=[
       {
           "role": "user",
           "content": "write a very long poem about a dog.",
       },
       output_json[0]
   ]
)

print(json.dumps(compacted_response.model_dump(), indent=2))

5. Agentic Steerability and User Updates

GPT-5.2 is strong on agentic scaffolding and multi-step execution when prompted well. Key tweaks include:

Updated specification:

6. Tool-Calling and Parallelism

GPT-5.2 improves on 5.1 in tool reliability and scaffolding. Best practices include:

Tool usage rules:

7. Structured Extraction, PDF, and Office Workflows

GPT-5.2 shows strong improvements in this area. Key recommendations:

Example extraction specification:

Always follow the schema exactly (no extra fields). If a field is not present in the source, set it to null rather than guessing. Before returning, quickly re-scan the source for any missed fields and correct omissions.

For multi-table/multi-file extraction:

8. Prompt Migration Guide to GPT-5.2

Migration mapping for reasoning_effort:

Current ModelTarget ModelTarget reasoning_effortNotes
GPT-4oGPT-5.2noneTreat 4o/4.1 migrations as “fast/low-deliberation” by default
GPT-4.1GPT-5.2noneSame mapping as GPT-4o
GPT-5GPT-5.2same value (except minimal → none)Preserve none/low/medium/high
GPT-5.1GPT-5.2same valuePreserve existing effort selection

Note: Default reasoning level for GPT-5 is medium; for GPT-5.1 and GPT-5.2 is none.

Migration steps:

  1. Switch models without changing prompts yet. Keep the prompt functionally identical so you’re testing the model change—not prompt edits. Make one change at a time.

  2. Pin reasoning_effort. Explicitly set GPT-5.2 reasoning_effort to match the prior model’s latency/depth profile.

  3. Run Evals for a baseline. After model + effort are aligned, run your eval suite.

  4. If regressions occur, tune the prompt. Use targeted constraints (verbosity/format/schema, scope discipline) to restore parity or improve.

  5. Re-run Evals after each small change. Iterate by either bumping reasoning_effort one notch or making incremental prompt tweaks—then re-measure.

9. Web Search and Research

GPT-5.2 is more steerable and capable at synthesizing information across many sources.

Best practices:

Web search rules:

10. Conclusion

GPT-5.2 represents a meaningful step forward for teams building production-grade agents prioritizing accuracy, reliability, and disciplined execution. It delivers stronger instruction following, cleaner output, and more consistent behavior across complex, tool-heavy workflows.

Most existing prompts migrate cleanly when reasoning effort, verbosity, and scope constraints are preserved during transition. Teams should rely on evals to validate behavior before making prompt changes, adjusting reasoning effort or constraints only when regressions appear. With explicit prompting and measured iteration, GPT-5.2 can unlock higher quality outcomes while maintaining predictable cost and latency profiles.

Appendix: Example Prompt for a Web Research Agent

The guide includes a comprehensive example prompt covering:

Core Mission

Answer questions fully with sufficient evidence for skeptical readers. Never invent facts. Default to detailed, useful answers unless explicitly asked for brevity. Go one step further by adding high-value adjacent material.

Persona

Be the world’s greatest research assistant. Engage warmly and honestly, avoiding ungrounded flattery. Adopt requested personas. Use natural, conversational tone unless the subject matter requires seriousness.

Factuality and Accuracy

Must browse the web and include citations for non-creative queries unless explicitly told not to. Must browse for time-sensitive topics, up-to-date or niche topics, travel planning, recommendations, generic topics, navigational queries, and any ambiguous terms.

Citations Required

Include citations after paragraphs containing web-derived claims. Don’t invent citations. Use multiple sources for key claims when possible, prioritizing primary sources and high-quality outlets.

How You Research

Conduct deep research for comprehensive answers. Start with multiple targeted searches using parallel searches when helpful. Deeply and thoroughly research until you have sufficient information. Begin broad enough to capture the main answer and most likely interpretations. Add targeted follow-up searches to fill gaps, resolve disagreements, or confirm important claims. Keep iterating until additional searching is unlikely to materially change the answer.

Writing Guidelines

Required Value-Add Behavior

Handling Ambiguity Without Asking Questions

If You Cannot Fully Comply