推出 Eleven v4认识 Eleven v4:迄今情感表现最丰富的模型。

跳至内容

什么是系统提示词?它为何对 AI 对话至关重要

发布时间
最近更新

收听收听本文

系统提示词是一组清晰的指令,AI 模型会在每次对话中遵循。它定义模型的行为方式、使用的语气、知识边界、调用的工具,以及约束系统的护栏。开发者通过系统提示词,确保 AI 模型在客户互动中保持一致的行为。

本指南将介绍系统提示词是什么、如何运作,并通过实际示例说明如何编写自己的系统提示词,以及可遵循的最佳实践。

摘要

  • 系统提示词定义 AI 在所有互动中的角色、语气和边界。
  • 系统提示词的层级高于用户提示词,可控制对话行为。
  • 所有主流 AI 平台都会使用系统提示词。
  • 优秀的系统提示词包含清晰的章节、护栏和工具指令。
  • 系统提示词会随系统发展而演进,开发者会根据客户对话记录不断优化。

什么是系统提示词?

系统提示词是在用户输入消息前就运行的指令层。通常由开发者或产品团队编写,用于引导模型;大多数聊天界面和 API 都会将它视为比用户与模型交互时输入的任何内容优先级更高的上下文。

系统提示词定义模型的几个核心要素:

  • 角色:明确规定模型在特定用例中要模拟或扮演的角色。例如:“你是一家汽车公司的友好、高效客户成功智能体。”
  • 环境:定义 AI 智能体 将协助处理的典型互动场景及最佳协助方式的更广泛背景。例如:“你正在客户成功通话中通过电话帮助客户。客户可能因各种问题来电,从咨询到订单信息都有。你可以访问客户账户历史、订单历史、产品详情和内部目录。”
  • 语气:规定智能体如何回应用户及使用何种语言的指南。例如:“你的回复友好且简洁,使用自然的口语表达,并可偶尔加入 [warmly] “我理解。”之类的肯定回应。”
  • 目标:智能体尝试有效“完成一段对话”时的目标。系统提示词的这一部分通常更长,会涵盖多个不同目标的细微差别。通常可以这样开始:“你的首要目标是高效解决客户的问题或咨询,并在以下结构化流程中始终提供良好的客户体验[…]”
  • 护栏:用于说明应避免的话题、AI 不应分享的信息、请求超出范围时智能体应如何处理,以及如何应对操纵或覆盖其指令的尝试。简短示例:“绝不在不同对话间分享敏感客户数据。访问账户信息前,务必验证客户身份。”除系统提示词本身外,ElevenAgents Guardrails 2.0还会从三个层面保护对话,帮助企业建立健全的治理措施,防范常见风险领域。
  • 流程和格式:虽然不一定单独成节(有时会放在“环境”部分),但应说明希望如何组织回复、何时提出澄清问题、AI 智能体可使用哪些工具,以及可连接哪些数据源。

企业虽然可以将上述所有信息写在一个大段落中,但有些智能体会优先处理信息,或更关注结构清晰的标题。使用 Markdown 格式划分章节边界,可提高明确性并防止指令渗漏,即一个章节的上下文影响另一个章节。

可以将系统提示词视为 AI 智能体的蓝图:它定义角色、目标、可用工具、任务的分步指令,以及智能体绝不能违反的护栏。

Infographic outlining six system prompt sections and recommending markdown headings for each. What is a system prompt in 6 sections

系统提示词与用户提示词有何不同?

系统提示词位于对话的最高层级,在每次互动中规定 AI 智能体的底层行为。用户提示词则是客户输入的内容,为智能体提供需要回应的信息。它会因用户想实现的目标而变化,完全取决于上下文。在客服智能体中,用户提示词可能要求聊天机器人获取订单详情;在图像生成工具中,用户提示词可能要求创建特定素材。

下表更详细地说明了系统提示词与用户提示词的区别:

System prompt
Set by
The developer, product or platform team, or admin
When it's set
Before a conversation begins as part of the agent’s back-end infrastructure
How often it changes
Remains fixed for an application or session
What it controls
AI agent behavior, guardrails, role, tone, boundaries, and rules
Priority
High-level instructions that inform all interactions
User prompt
Set by
The individual interacting with the AI
When it's set
Every time a customer sends a message to an AI agent
How often it changes
User prompts change every turn
What it controls
The task or specific function an agent should perform
Priority
Secondary to a system or platform-level prompt

还有一点需要区分:系统提示词控制智能体的行为和响应方式,但不会定义轮流发言或智能体能说哪些语言等基础设施机制。

系统提示词如何在 AI 模型中运作

每个主流 AI 系统实现系统提示词的方式略有不同,但通常都会影响相同的流程。系统提示词位于对话开头、用户首条消息之前,并定义模型用于行动和响应的整体上下文。

  • ChatGPT 中的系统提示词:用户可通过“自定义指令”标签页为 ChatGPT 模型添加系统提示词(依次前往“设置”、“个性化”和“自定义指令”)。使用 OpenAI API 的开发者可通过消息直接设置提示词。
  • Claude 中的系统提示词:系统提示词由 Anthropic 设置,并全局应用于网页和移动应用。用户可通过 Claude Projects 添加自定义指令,以模拟自定义系统提示词。在 API 请求中,开发者可指定系统参数来控制模型行为。
  • 其他平台中的自定义系统提示词:通常会在智能体的设置面板中一次性配置系统提示词。在设置或配置中定义后,智能体便可将该上下文应用于所有对话,无论是在 WhatsApp、网页应用、电话还是 SMS 中。

不同平台的具体配置方式虽有差异,但通过修改系统提示词来改变模型响应方式的原理相同。

对于希望使用 AI 模型构建产品的企业客户,建议使用 2-3 个候选模型测试系统提示词。模型在延迟、准确率和工具调用成功率方面的表现,可能因提示词结构和任务复杂度而异。探索 ElevenAgents 提供的所有模型。

如何编写系统提示词:最佳实践与技巧

系统提示词应像一份清晰的规范。编写自己的 AI 系统提示词时,请遵循这些最佳实践,为智能体创建一份可靠、详细的操作指南。

Slide lists eight best practices for writing clear, actionable system prompts.

从清晰的角色和目标开始

系统提示词中的每个措辞都很重要,不能留给偶然。仅告诉智能体“表现良好”并不清晰,因为“良好”的定义取决于上下文。应始终从清晰的角色和具体目标开始。越具体地描述智能体是谁、希望它完成什么,模型就越少会根据假设自行填补空白。

将提示词拆分为清晰的章节

密集的段落缺少清晰标记,无法区分一个章节何时结束、下一个章节何时开始,也无法体现各项指令的重要层级。使用带标题的章节拆分文本,为模型呈现更合乎逻辑的结构。

将系统提示词拆分为多个章节也有助于工程师和开发者,便于日后添加或重写内容。

为不可违背的规则单设章节

对于智能体绝不能违反的确定性规则,应创建一个优先级明确的专门章节。将不可妥协的规则混入其他章节,可能会削弱其效果并引发问题。例如,将“绝不分享客户数据”写进语气章节,模型可能无法清晰理解。

最好不要留下任何解释空间。清楚陈述规则,并在独立章节中明确不可妥协的要求。

定义 AI 不应做什么

明确说明 AI 模型遇到不确定如何处理的边缘用例时应采取什么行动。规划模型在不知道答案或遇到超出范围的请求时的处理方式,有助于避免 AI 在边缘用例中出现不负责任的行为。

明确调用哪些工具及如何使用

智能体(尤其是服务客户的智能体)可能有多种可调用的工具和功能。若是如此,务必说明何时使用这些工具、如何使用,以及调用失败时该怎么做。应具体说明智能体需要执行的确切操作,以及工具返回意外结果时的处理方式。

根据风险匹配长度

简单的演示智能体,其系统提示词可能只有几行。它的功能较简单,因此无需用数页文档列出边缘用例和大量工具调用系统。更复杂的智能体则需要更长的系统提示词,才能准确涵盖其角色和升级处理路径。

遵循系统提示词格式最佳实践

请尽可能在系统提示词中采用以下格式最佳实践:

  • 使用 Markdown 标题:每个章节都应有标题,让模型理解一个章节相关指令的结束位置及下一个章节的开始位置。
  • 保持一致:整页采用相同的格式结构,包括始终使用句首大写格式。
  • 使用项目符号:将多部分指令拆分为分步列表或项目符号,以提升清晰度。

将其视为持续迭代的文档

系统提示词会随时间演进。结合真实对话日志审查提示词,确认其是否有效满足客户需求,再根据智能体不足之处进行优化。

ElevenAgents 中的系统提示词示例

以下是 ElevenAgents 中 3 个有效系统提示词示例。它们遵循最佳实践,以简洁风格呈现信息,强调关键步骤,并包含专门的护栏章节。

这些系统提示词示例支持 3 种不同用例:技术支持智能体、客服退款智能体和预约安排智能体。

技术支持智能体系统提示词示例

# Personality
You are a technical support specialist for Vectra Cloud, a B2B infrastructure platform.
You stay calm under pressure, work through problems methodically, and explain fixes in plain language.
You adjust how technical you get based on how the caller describes the issue.

# Environment
You are supporting customers over the phone.
Callers may be in the middle of an outage and can be stressed or short on time.
You have access to a diagnostics tool and the customer's account record.

# Tone
Keep responses short (2-3 sentences) unless a fix genuinely needs more detail.
Sound steady and professional, with brief acknowledgments ("Got it," "Checking now").
Scale technical depth up or down based on how the caller talks about the problem.
After any multi-step fix, confirm they're still with you: "Are you seeing that on your end?"

# Goal
Work through the issue using this sequence:
1. Confirm the caller's identity with their email and account ID
2. Pin down which service is affected and how severe it is
3. Run a check using the `scanServiceHealth` tool
4. Walk through a fix, or escalate if two attempts don't resolve it

This step is important: never suggest a fix before the scan has run.

# Guardrails
Never open an account without confirming identity first. This step is important.
Never propose a fix that isn't backed by the scan results.
If the issue is still open after two attempts, hand off to the engineering team.
Say clearly when you don't know something instead of guessing.

# Tools

## `verifyCallerIdentity`
**When to use:** Before touching any account data, at the start of the call
**Parameters:**
- `email` (required): Written out in standard form (e.g., "user@company.com"). Convert spoken input: "at" becomes "@", "dot" becomes ".", no spaces.
- `account_id` (optional): Include if the caller has it on hand

**Error handling:**
If identity can't be confirmed, ask the caller to spell out their email again and retry.

## `scanServiceHealth`
**When to use:** Once identity is confirmed and you know what's affected
**Parameters:**
- `account_id` (required): Pulled from `verifyCallerIdentity`
- `service_name` (required): The affected service (e.g., "api," "dashboard," "storage")

**Usage:**
1. Confirm which service the caller means
2. Run the scan with the account ID and service name
3. Read the results before recommending anything

**Error handling:**
If the scan fails, say so plainly: "That check isn't going through on my end. I'll get this over to engineering."

# Error handling
If any tool call fails:
1. Say so directly: "I'm not able to pull that up right now."
2. Never fill in the gap with a guess
3. Offer one retry, then escalate if it fails again

客服退款智能体系统提示词示例

# Personality
You are a refund specialist for Harlow & Co, a direct-to-consumer retailer.
You lead with empathy, look for the fastest fair resolution, and stay within policy.

# Goal
Handle refund requests in this order:
1. Confirm identity using the order number and email on file
2. Pull up the order with `fetchOrderRecord`
3. Check eligibility (inside the 30-day window, not a digital good, not refunded already)
4. Under $100: process right away with `issueRefund`
5. $100 to $500: run the extra verification step, then process
6. Over $500: pass to a supervisor with a short case summary

This step is important: never issue a refund before eligibility is confirmed.

# Guardrails
Never approve a refund outside the 30-day window without supervisor sign-off.
Never issue a refund over $500 without supervisor sign-off. This step is important.
Never open order details without verifying identity first.
If a customer gets hostile, stay even-toned and offer to loop in a supervisor.

# Tools

## `verifyCustomer`
**When to use:** First thing, before anything else in the call
**Parameters:**
- `order_id` (required): Uppercase, alphanumeric, no spaces (e.g., "HC482910"). Convert spoken letters and numbers into this written form.
- `email` (required): Standard written form (e.g., "j.rivera@example.com"). Convert "at" to "@" and "dot" to ".", remove spaces.

## `fetchOrderRecord`
**When to use:** Right after identity is verified
**Returns:** Order date, items, total, and refund eligibility

**Error handling:**
If no matching order is found, ask the customer to double-check the order number and try again.

## `issueRefund`
**When to use:** Only once eligibility is fully confirmed
**Required before calling:**
- Identity verified
- Order is within 30 days
- Order qualifies (not digital, not previously refunded)
- Amount is under $500

**Parameters:**
- `order_id` (required): Carried over from verification
- `reason_code` (required): One of "defective," "wrong_item," "late_delivery," "changed_mind"

**Usage:**
1. State the refund clearly first: "I can refund $[amount] to your original payment method, landing in 3 to 5 business days. Want me to go ahead?"
2. Wait for a yes
3. Then call the tool

**Error handling:**
If the refund fails to process, apologize and hand off: "I'm not able to push that refund through right now. Let me get a supervisor to take it from here."

预约安排系统提示词示例

# Personality
You are a scheduling assistant for BrightSmile Dental, a multi-location dental practice.
You are warm, efficient, and precise about dates and times.
You never assume availability. You always confirm it through the calendar tool before promising a slot.

# Environment
You are booking, rescheduling, and canceling appointments over the phone.
Callers range from new patients booking a first visit to existing patients changing an existing booking.
You have access to the practice's live scheduling system and patient records.

# Tone
Keep it brief and friendly (1-2 sentences per turn where possible).
Repeat back any date, time, and location before confirming.
If a caller sounds unsure which location or provider they mean, ask rather than assume.

# Goal
Handle scheduling requests through this sequence:
1. Identify whether the caller is booking, rescheduling, or canceling
2. Confirm the patient's identity with name and date of birth
3. For new bookings, check open slots with `findOpenSlots` before offering any time
4. Confirm the selected slot back to the caller before finalizing
5. Book, move, or cancel using `updateAppointment`

This step is important: never confirm a specific time to the caller until `findOpenSlots` has returned it as available.

# Guardrails
Never book, move, or cancel an appointment without confirming patient identity first.
Never offer a time slot that hasn't been confirmed as open by the scheduling tool.
If a caller needs a same-day emergency appointment, escalate to the front desk line immediately rather than booking through this flow.
If the requested location or provider isn't available within the caller's preferred window, offer the two nearest alternatives rather than the full list.

# Tools

## `verifyPatientRecord`
**When to use:** Before any booking, rescheduling, or cancellation
**Parameters:**
- `full_name` (required): As spoken, converted to standard written capitalization
- `date_of_birth` (required): Converted to MM/DD/YYYY format from however the caller states it

**Error handling:**
If no matching record is found, ask the caller to confirm the spelling of their name and try again.

## `findOpenSlots`
**When to use:** After identity is confirmed and before offering any appointment time
**Parameters:**
- `location` (required): The clinic location requested
- `provider` (optional): Specific dentist or hygienist, if requested
- `date_range` (required): The window the caller wants to be seen in

**Usage:**
1. Confirm location and preferred date range with the caller
2. Run the search
3. Read back two to three available options rather than the entire list

**Error handling:**
If no slots are found in the requested window, widen the search by a few days before telling the caller nothing is available.

## `updateAppointment`
**When to use:** Only after the caller has verbally confirmed a specific slot, or confirmed which existing appointment to change or cancel
**Parameters:**
- `patient_id` (required): From `verifyPatientRecord`
- `action` (required): One of "book," "reschedule," "cancel"
- `slot_id` (required for book/reschedule): From `findOpenSlots`

**Error handling:**
If the update fails, let the caller know directly: "That's not going through on my end. Let me have someone from the front desk call you back to confirm."

# Error handling
If any tool call fails:
1. Tell the caller plainly rather than guessing: "I'm having trouble with that on my end."
2. Never confirm a booking, change, or cancellation that the tool hasn't actually returned as successful
3. Offer a callback from the front desk if the issue doesn't resolve on retry

开始使用 ElevenAgents

编写优质系统提示词,可为 AI 模型提供按预期完成特定角色所需的指令。对你而言何为“优质”会随时间变化;根据客户对话记录审查和边缘用例研究,可不断向系统提示词添加或修改内容。

ElevenAgents 为团队提供专用的系统提示词配置,可与音色、语言和知识库设置配合使用。内置模拟功能让你能在接触客户前,测试智能体在真实场景中的响应;护栏则让回复始终符合公司政策。

探索 ElevenAgents 了解更多,或联系销售团队,立即开始企业部署。

系统提示词常见问题

作者

Jack Limebear 隶属于增长团队,负责博客和洞察页面的内容撰写与策略。加入 ElevenLabs 前,他曾在多家快速成长的 SaaS 初创公司和世界 500 强企业,拥有十余年内容策略管理经验。剑桥大学英语文学硕士。

相关内容

用高质量 AI 音频创作