System Prompt
Define your Agent's core identity, tone, and behavior guidelines.
The System Prompt is an instruction injected at the beginning of every conversation. It defines the Agent's identity, tone, scope, and response style. A well-crafted prompt ensures your Agent maintains a consistent brand voice in any context.
Where to Configure
Edit the prompt in the Lens OS console under Settings → System Prompt. Changes take effect immediately — no redeployment needed.
Prompt Structure
Identity
Tell the Agent who it is and who it serves:
Example
You are "Book Assistant", an AI customer service agent for an online bookstore.
You serve readers who are interested in books.
Always respond in a friendly, professional tone.Scope
Clearly define what the Agent can and cannot do:
Example
You can:
- Recommend books based on user interests
- Look up order status and shipping progress
- Explain return and refund policies
You cannot:
- Modify shipping info on orders that have already shipped
- Suggest purchasing from external platformsTone & Style
Define response tone, length, and format:
Example
Response style:
- Friendly tone, avoid overly formal language
- Keep responses concise, under 200 words
- When recommending books, suggest at most 3 per response
- For unsupported requests, guide users to contact supportDynamic Injection
The system prompt can be dynamically overridden in createAgentHandler, useful for personalizing behavior per user:
src/app/api/lens/agent/chat/route.ts
import { createAgentHandler } from "@lens-os/sdk/server";
import { auth } from "@/auth";
const handler = createAgentHandler({
apiKey: process.env.LENS_OS_API_KEY!,
openaiKey: process.env.LENS_MODEL_API_KEY!,
// Dynamically adjust prompt based on user identity
systemPrompt: async (context) => {
const session = await auth();
const userName = session?.user?.name ?? "Guest";
return `The user you are serving is ${userName}. Address them by name.`;
},
});
export const { POST } = handler;Note
The system prompt set in the console serves as the base.
systemPrompt function output is appended after it. If you only need static content, configure it in the console — no code needed.Best Practices
- Be specific — "Respond in under 150 words" works better than "be concise"
- Use positive framing — Tell the Agent what to do, not just what to avoid
- Version your prompts — Record the current version before each update so you can roll back
- Test before saving — Use the console test chat to validate behavior before committing
Tip
Rules can complement the system prompt for fine-grained behavioral control. The two work best together — see the Rules documentation.