Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(prompts): enforce user perspective in input completion (#13619)

Arvin Xubd8143c46437
diff --git a/packages/prompts/src/chains/inputCompletion.ts b/packages/prompts/src/chains/inputCompletion.ts
index bd4168c1692..5c9b984cb6f 100644
--- a/packages/prompts/src/chains/inputCompletion.ts
+++ b/packages/prompts/src/chains/inputCompletion.ts
@@ -15,17 +15,27 @@ ${context.map((m) => `${m.role}: ${m.content}`).join('\n')}`;
max_tokens: 100,
messages: [
{
- content: `Complete the user's partially typed message. Output ONLY the missing text to insert at the cursor. Keep it short and natural. No explanations.
+ content: `You are an autocomplete engine for a chat input box. The user is composing a message to send to an AI assistant. Predict and complete what the USER is typing. Output ONLY the missing text to insert at the cursor.
-Examples of expected behavior:
-User: Before cursor: "How do I " / After cursor: ""
-Output: implement authentication in Next.js?
+CRITICAL RULES:
+- You are completing the USER's message, NOT the AI assistant's response
+- The completed text should read as something a human would type to ask, request, or tell an AI
+- NEVER generate text that sounds like an AI assistant responding (e.g., "help you", "assist you", "I can help")
+- Keep it short and natural, under 15 words
+- Match the user's language
-User: Before cursor: "Can you explain the difference between " / After cursor: ""
-Output: useEffect and useLayoutEffect in React?
+GOOD examples (user perspective):
+"How can I " → "optimize my React component's performance?"
+"Hi" → ", I need help with a TypeScript issue"
+"Can you " → "explain how useEffect cleanup works?"
+"帮我" → "写一个数据库查询的优化方案"
+"Let me " → "describe the bug I'm seeing"
+"我想" → "了解一下如何部署到 Kubernetes"
-User: Before cursor: "我想了解一下" / After cursor: ""
-Output: 如何在项目中使用 TypeScript 的泛型${contextBlock}`,
+BAD examples (assistant perspective — NEVER do this):
+"How can I " → "help you today?" ← WRONG: this is what an AI assistant says
+"Hi" → ", how can I help you?" ← WRONG: assistant greeting
+"Let me " → "explain that for you" ← WRONG: assistant offering to explain${contextBlock}`,
role: 'system',
},
{