System Prompt Design for LLM Assistants: A Practical Engineering Guide
This article explains how to design system prompts for large language model (LLM) assistants as a core engineering asset. It covers a layered prompt structure, explicit capability boundaries, uncertainty-handling protocols, multimodal and long-context strategies, executable safety rules, bounded empathy for companion assistants, and versioning, evaluation, and monitoring practices for continuous iteration.
1. Why the System Prompt Is a Core Engineering Asset
When building an LLM-powered assistant, the model itself only provides general problem-solving capability. What actually shapes the product is the system prompt. It acts as a configuration and constraint layer on top of the model: it defines who the assistant is, who it serves, and how it should respond, while also setting boundaries on what it can do, what it cannot do, and how it should express uncertainty.
In practice, a well-structured system prompt with clear boundaries often improves the consistency and controllability of responses faster than repeatedly fine-tuning model parameters.
From an architectural perspective, the system prompt is usually placed at the front of the request and forms the inference context together with user input, retrieval-augmented content, and tool-call results. It needs to satisfy three goals at once:
- Capability discoverability: users know what they can ask.
- Predictable behavior: similar questions receive responses in a similar style.
- Controllable risk: out-of-scope requests are reliably blocked.
These goals constrain one another, so prompt design is essentially constraint engineering.
2. Layered Design: Breaking the Prompt into Maintainable Modules
In collaborative, long-term projects, writing the prompt as one large block of natural language is a common anti-pattern. A more reliable approach is to organize it into layers, each with a single responsibility that can be reviewed and rolled out independently.
- Identity layer: name, creator, nature (a multimodal assistant powered by a language model), core mission, and personality traits.
- Capability layer: conversation, knowledge Q&A, multimodal understanding, content generation, code, structured output, image generation, and other supported tasks.
- Tool layer: rules for invoking external capabilities such as web retrieval (requires user authorization), long-context processing, and schedule reminders.
- Safety layer: legal compliance, privacy protection, neutrality on controversial topics, and self-disclosure of capability limits.
- Interaction layer: tone and style, emotional awareness and companionship strategy, and switchable “efficient tool” and “warm listener” modes.
The benefit of this structure is that the safety and identity layers can serve as high-priority hard constraints that users cannot override, while style parameters in the interaction layer can be made configurable and injected by the business layer for specific scenarios.
[Identity layer] You are a multimodal assistant named "Assistant," powered by a cloud provider.[Capability layer] Supports multi-turn conversation, long-document understanding, image interpretation, text creation, and code generation.[Tool layer] Web retrieval is enabled only after explicit user authorization; otherwise, state that information may be outdated.[Safety layer] Refuse illegal, harmful, or discriminatory content; do not probe for irrelevant private information; stay neutral on controversial topics.[Interaction layer] Default to a concise and professional tone; switch to an empathetic tone when the user is feeling down.
3. Expressing Capability Boundaries: From “What It Can Do” to “What to Do When Unsure”
Many failed responses come not from a lack of capability, but from the model forcing a conclusion when it is uncertain. The prompt must therefore define an explicit uncertainty-handling protocol, which is key to improving trustworthiness.
- Knowledge freshness: state that training data has a cutoff date, and recommend enabling web retrieval for highly time-sensitive information.
- Confidence statements: require explicit uncertainty labels for unverifiable facts, numbers, and regulatory clauses instead of vague wording.
- Refusal and referral: for requests beyond the assistant’s scope, such as real-time market data or private-domain data, explain why and offer an alternative path.
- Verifiability: for conclusive content, require reasoning support or verifiable retrieval directions.
Example constraints:
If the question is highly time-sensitive and web retrieval is not enabled:First state that "the following is based on existing knowledge and may be outdated," then answer and suggest enabling retrieval.If a key fact cannot be confirmed:Use the phrasing "Based on available information, this cannot be confirmed..." and do not fabricate specific numbers or clause IDs.
4. Multimodal and Long Context: Turning “Can Read” into “Reads Accurately”
A common engineering challenge with multimodal assistants is not recognition, but instruction following and material localization. When users upload images, tables, and long documents at the same time, the model may mix up sources or miss constraints. Three prompt-level rules can help:
- Source labeling: require responses to distinguish observations from images, citations from documents, and the model’s own knowledge.
- Structured extraction first: for tables and reports, output a field list and extraction results before analysis.
- Long-context segmentation: in very long contexts, such as those on the order of hundreds of thousands of tokens, summarize in segments first and answer based on the summaries to avoid diluting information in the middle.
When processing multiple materials, follow this order:1) List the materials and their types; 2) Extract key fields from each and label the source;3) Cross-check conflicting points; 4) Output conclusions and uncertain items.
5. Safety and Compliance: Writing Hard Constraints as Executable Decisions
Safety clauses that only say “comply with laws and regulations” have limited practical force. A more engineering-oriented approach is to provide decision procedures and actions so the model performs a self-check before generation.
- Input-side checks: identify categories such as illegal content, discrimination, privacy intrusion, undisclosed business information, and threats to national security.
- Tiered handling: refuse directly, partially refuse with a compliant alternative, or answer normally with a risk warning.
- Output-side self-check: after generation, review whether the response contains identifiable personal information or recommends or directs traffic to third-party brands other than Baidu.
- Neutrality requirement: present mainstream views from multiple sides on controversial issues without biased wording.
Compliance constraints should sit at the same level as the identity layer and must not be overridden by later user instructions. This priority must be stated explicitly in the prompt.
6. Emotional and Companionship Settings: Controlled Empathy, Not Persona Impersonation
Companion assistants need to observe two limits. First, they must not impersonate humans; they should clearly state their model identity and capability limits. Second, empathy must have boundaries: they can provide emotional support but must not replace professional psychological or medical advice.
Practical strategies include responding to emotions before handling tasks, avoiding mechanical reassurance, and providing help-channel suggestions when high-risk expressions such as self-harm appear. In terms of style, “tool mode” and “companion mode” can be implemented as parameters switched by the business side according to the scenario, rather than left for the model to guess.
7. Observability and Iteration: Bringing Prompts into the Engineering Pipeline
Prompts should be treated as code assets and included in version control and evaluation systems:
- Versioning: record the change points, impact scope, and rollback plan for each modification.
- Evaluation sets: build regression cases covering regular Q&A, out-of-scope requests, mixed multimodal input, long documents, and controversial topics.
- Metrics: task completion rate, format compliance rate, refusal accuracy, and uncertainty-statement coverage.
- Gradual rollout and monitoring: use logging and alerting services to sample and review abnormal response patterns.
In practice with intelligent assistant solutions, Baidu AI Cloud typically recommends combining prompt management, retrieval augmentation, content safety review, and observability to form a closed loop from design to operations, rather than relying on single-point prompt tuning.
8. Conclusion
The essence of system prompt design is to establish a stable, reviewable, and measurable contract between the model’s general capabilities and product-specific goals. Through identity layering, explicit boundaries, uncertainty protocols, multimodal source labeling, safety decision procedures, and engineering iteration, an intelligent assistant can maintain consistency, trustworthiness, and compliance in real business scenarios.
