@elizaos/prompts 2.0.0-alpha.53 → 2.0.0-alpha.533
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/python/prompts.py +830 -261
- package/dist/rust/prompts.rs +811 -262
- package/dist/typescript/index.d.ts +40 -0
- package/dist/typescript/index.ts +849 -260
- package/package.json +4 -4
- package/prompts/add_contact.txt +29 -0
- package/prompts/choose_option.txt +4 -7
- package/prompts/extract_secret_operation.txt +20 -0
- package/prompts/extract_secret_request.txt +16 -0
- package/prompts/extract_secrets.txt +17 -0
- package/prompts/image_description.txt +8 -15
- package/prompts/image_generation.txt +4 -7
- package/prompts/initial_summarization.txt +28 -0
- package/prompts/long_term_extraction.txt +128 -0
- package/prompts/message_classifier.txt +37 -0
- package/prompts/message_handler.txt +45 -95
- package/prompts/multi_step_decision.txt +6 -13
- package/prompts/multi_step_summary.txt +4 -10
- package/prompts/option_extraction.txt +4 -9
- package/prompts/post_action_decision.txt +35 -0
- package/prompts/post_creation.txt +14 -25
- package/prompts/reflection.txt +8 -11
- package/prompts/reflection_evaluator.txt +37 -32
- package/prompts/remove_contact.txt +20 -0
- package/prompts/reply.txt +5 -8
- package/prompts/schedule_follow_up.txt +28 -0
- package/prompts/search_contacts.txt +23 -0
- package/prompts/should_follow_room.txt +18 -0
- package/prompts/should_mute_room.txt +18 -0
- package/prompts/should_respond.txt +38 -37
- package/prompts/should_respond_with_context.txt +42 -0
- package/prompts/should_unfollow_room.txt +18 -0
- package/prompts/should_unmute_room.txt +18 -0
- package/prompts/think.txt +25 -0
- package/prompts/update_contact.txt +27 -0
- package/prompts/update_entity.txt +6 -13
- package/prompts/update_role.txt +29 -0
- package/prompts/update_settings.txt +5 -12
- package/prompts/update_summarization.txt +30 -0
- package/scripts/generate-action-docs.js +109 -1
- package/scripts/generate-plugin-prompts.js +21 -2
package/dist/python/prompts.py
CHANGED
|
@@ -10,6 +10,36 @@ These prompts use Handlebars-style template syntax:
|
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
ADD_CONTACT_TEMPLATE = """task: Extract contact information to add to the relationships.
|
|
14
|
+
|
|
15
|
+
context:
|
|
16
|
+
{{providers}}
|
|
17
|
+
|
|
18
|
+
recent_messages:
|
|
19
|
+
{{recentMessages}}
|
|
20
|
+
|
|
21
|
+
current_message:
|
|
22
|
+
{{message}}
|
|
23
|
+
|
|
24
|
+
instructions[5]:
|
|
25
|
+
- identify the contact name being added
|
|
26
|
+
- include entityId only if it is explicitly known from context
|
|
27
|
+
- return categories as a comma-separated list
|
|
28
|
+
- include notes, timezone, and language only when clearly present
|
|
29
|
+
- include a short reason for why this contact should be saved
|
|
30
|
+
|
|
31
|
+
output:
|
|
32
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
contactName: Jane Doe
|
|
36
|
+
entityId:
|
|
37
|
+
categories: vip,colleague
|
|
38
|
+
notes: Met at the design summit
|
|
39
|
+
timezone: America/New_York
|
|
40
|
+
language: English
|
|
41
|
+
reason: Important collaborator to remember"""
|
|
42
|
+
|
|
13
43
|
AUTONOMY_CONTINUOUS_CONTINUE_TEMPLATE = """Your job: reflect on context, decide what you want to do next, and act if appropriate.
|
|
14
44
|
- Use available actions/tools when they can advance the goal.
|
|
15
45
|
- Use thinking to think about and plan what you want to do.
|
|
@@ -84,38 +114,86 @@ CHOOSE_OPTION_TEMPLATE = """# Task: Choose an option from the available choices.
|
|
|
84
114
|
Analyze the options and select the most appropriate one based on the current context.
|
|
85
115
|
Provide your reasoning and the selected option ID.
|
|
86
116
|
|
|
87
|
-
Respond using
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
117
|
+
Respond using TOON like this:
|
|
118
|
+
thought: Your reasoning for the selection
|
|
119
|
+
selected_id: The ID of the selected option
|
|
120
|
+
|
|
121
|
+
IMPORTANT: Your response must ONLY contain the TOON document above."""
|
|
122
|
+
|
|
123
|
+
EXTRACT_SECRET_OPERATION_TEMPLATE = """You are helping manage secrets for an AI agent.
|
|
124
|
+
|
|
125
|
+
Determine what operation the user wants to perform:
|
|
126
|
+
- get: Retrieve a secret value
|
|
127
|
+
- set: Store a new secret
|
|
128
|
+
- delete: Remove a secret
|
|
129
|
+
- list: Show all available secrets (without values)
|
|
130
|
+
- check: Check if a secret exists
|
|
131
|
+
|
|
132
|
+
Common patterns:
|
|
133
|
+
- "What is my OpenAI key?" -> operation: get, key: OPENAI_API_KEY
|
|
134
|
+
- "Do I have a Discord token set?" -> operation: check, key: DISCORD_BOT_TOKEN
|
|
135
|
+
- "Show me my secrets" -> operation: list
|
|
136
|
+
- "Delete my old API key" -> operation: delete
|
|
137
|
+
- "Remove TWITTER_API_KEY" -> operation: delete, key: TWITTER_API_KEY
|
|
138
|
+
- "Set my key to sk-..." -> operation: set, key: <infer>, value: sk-...
|
|
139
|
+
|
|
140
|
+
{{recentMessages}}
|
|
141
|
+
|
|
142
|
+
Extract the operation, key (if applicable), value (if applicable), and level from the user's message."""
|
|
143
|
+
|
|
144
|
+
EXTRACT_SECRET_REQUEST_TEMPLATE = """You are helping an AI agent request a missing secret.
|
|
145
|
+
Determine what secret the agent needs and why based on the recent conversation.
|
|
146
|
+
|
|
147
|
+
Common patterns:
|
|
148
|
+
- "I need an API key for OpenAI" -> key: OPENAI_API_KEY
|
|
149
|
+
- "Missing TWITTER_TOKEN" -> key: TWITTER_TOKEN
|
|
150
|
+
- "I cannot proceed without a Discord token" -> key: DISCORD_TOKEN
|
|
92
151
|
|
|
93
|
-
|
|
152
|
+
Recent Messages:
|
|
153
|
+
{{recentMessages}}
|
|
154
|
+
|
|
155
|
+
Output JSON with:
|
|
156
|
+
- key: The name of the secret needed (e.g. OPENAI_API_KEY)
|
|
157
|
+
- reason: Why it is needed (optional)
|
|
158
|
+
|
|
159
|
+
If no specific secret is requested, return null json."""
|
|
160
|
+
|
|
161
|
+
EXTRACT_SECRETS_TEMPLATE = """You are extracting secret/configuration values from the user's message.
|
|
162
|
+
|
|
163
|
+
The user wants to set one or more secrets. Extract:
|
|
164
|
+
1. The secret key (should be UPPERCASE_WITH_UNDERSCORES format)
|
|
165
|
+
2. The secret value
|
|
166
|
+
3. Optional description
|
|
167
|
+
4. Secret type (api_key, secret, credential, url, or config)
|
|
94
168
|
|
|
95
|
-
|
|
169
|
+
Common patterns:
|
|
170
|
+
- "Set my OpenAI key to sk-..." -> key: OPENAI_API_KEY, value: sk-...
|
|
171
|
+
- "My Anthropic API key is sk-ant-..." -> key: ANTHROPIC_API_KEY, value: sk-ant-...
|
|
172
|
+
- "Use this Discord token: ..." -> key: DISCORD_BOT_TOKEN, value: ...
|
|
173
|
+
- "Set DATABASE_URL to postgres://..." -> key: DATABASE_URL, value: postgres://...
|
|
96
174
|
|
|
97
|
-
|
|
175
|
+
{{recentMessages}}
|
|
176
|
+
|
|
177
|
+
Extract the secrets from the user's message. If the key name isn't explicitly specified, infer an appropriate UPPERCASE_WITH_UNDERSCORES name based on the context."""
|
|
178
|
+
|
|
179
|
+
IMAGE_DESCRIPTION_TEMPLATE = """Task: Analyze the provided image and generate a comprehensive description with multiple levels of detail.
|
|
180
|
+
|
|
181
|
+
Instructions:
|
|
98
182
|
Carefully examine the image and provide:
|
|
99
183
|
1. A concise, descriptive title that captures the main subject or scene
|
|
100
184
|
2. A brief summary description (1-2 sentences) highlighting the key elements
|
|
101
185
|
3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details
|
|
102
186
|
|
|
103
187
|
Be objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.
|
|
104
|
-
</instructions>
|
|
105
188
|
|
|
106
|
-
|
|
107
|
-
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
108
|
-
Go directly to the XML response format without any preamble or explanation.
|
|
189
|
+
Output:
|
|
109
190
|
|
|
110
|
-
Respond using
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>
|
|
115
|
-
</response>
|
|
191
|
+
Respond using TOON like this:
|
|
192
|
+
title: A concise, descriptive title for the image
|
|
193
|
+
description: A brief 1-2 sentence summary of the key elements in the image
|
|
194
|
+
text: An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image
|
|
116
195
|
|
|
117
|
-
IMPORTANT: Your response must ONLY contain the
|
|
118
|
-
</output>"""
|
|
196
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
|
|
119
197
|
|
|
120
198
|
IMAGE_GENERATION_TEMPLATE = """# Task: Generate an image prompt for {{agentName}}.
|
|
121
199
|
|
|
@@ -128,111 +206,260 @@ The prompt should be specific, descriptive, and suitable for AI image generation
|
|
|
128
206
|
# Recent conversation:
|
|
129
207
|
{{recentMessages}}
|
|
130
208
|
|
|
131
|
-
Respond using
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<prompt>Detailed image generation prompt</prompt>
|
|
135
|
-
</response>
|
|
209
|
+
Respond using TOON like this:
|
|
210
|
+
thought: Your reasoning for the image prompt
|
|
211
|
+
prompt: Detailed image generation prompt
|
|
136
212
|
|
|
137
|
-
IMPORTANT: Your response must ONLY contain the
|
|
213
|
+
IMPORTANT: Your response must ONLY contain the TOON document above."""
|
|
138
214
|
|
|
139
|
-
|
|
215
|
+
INITIAL_SUMMARIZATION_TEMPLATE = """# Task: Summarize Conversation
|
|
140
216
|
|
|
141
|
-
|
|
142
|
-
{{providers}}
|
|
143
|
-
</providers>
|
|
144
|
-
|
|
145
|
-
<instructions>
|
|
146
|
-
Write a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.
|
|
147
|
-
|
|
148
|
-
IMPORTANT ACTION ORDERING RULES:
|
|
149
|
-
- Actions are executed in the ORDER you list them - the order MATTERS!
|
|
150
|
-
- REPLY should come FIRST to acknowledge the user's request before executing other actions
|
|
151
|
-
- Common patterns:
|
|
152
|
-
- For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)
|
|
153
|
-
- For task execution: REPLY,SEND_MESSAGE or REPLY,EVM_SWAP_TOKENS (acknowledge first, then do the task)
|
|
154
|
-
- For multi-step operations: REPLY,ACTION1,ACTION2 (acknowledge first, then complete all steps)
|
|
155
|
-
- REPLY is used to acknowledge and inform the user about what you're going to do
|
|
156
|
-
- Follow-up actions execute the actual tasks after acknowledgment
|
|
157
|
-
- Use IGNORE only when you should not respond at all
|
|
158
|
-
- If you use IGNORE, do not include any other actions. IGNORE should be used alone when you should not respond or take any actions.
|
|
159
|
-
|
|
160
|
-
IMPORTANT ACTION PARAMETERS:
|
|
161
|
-
- Some actions accept input parameters that you should extract from the conversation
|
|
162
|
-
- When an action has parameters listed in its description, include a <params> block for that action
|
|
163
|
-
- Extract parameter values from the user's message and conversation context
|
|
164
|
-
- Required parameters MUST be provided; optional parameters can be omitted if not mentioned
|
|
165
|
-
- If you cannot determine a required parameter value, ask the user for clarification in your <text>
|
|
166
|
-
|
|
167
|
-
EXAMPLE (action parameters):
|
|
168
|
-
User message: "Send a message to @dev_guru on telegram saying Hello!"
|
|
169
|
-
Actions: REPLY,SEND_MESSAGE
|
|
170
|
-
Params:
|
|
171
|
-
<params>
|
|
172
|
-
<SEND_MESSAGE>
|
|
173
|
-
<targetType>user</targetType>
|
|
174
|
-
<source>telegram</source>
|
|
175
|
-
<target>dev_guru</target>
|
|
176
|
-
<text>Hello!</text>
|
|
177
|
-
</SEND_MESSAGE>
|
|
178
|
-
</params>
|
|
179
|
-
|
|
180
|
-
IMPORTANT PROVIDER SELECTION RULES:
|
|
181
|
-
- Only include providers if they are needed to respond accurately.
|
|
182
|
-
- If the message mentions images, photos, pictures, attachments, or visual content, OR if you see "(Attachments:" in the conversation, you MUST include "ATTACHMENTS" in your providers list
|
|
183
|
-
- If the message asks about or references specific people, include "ENTITIES" in your providers list
|
|
184
|
-
- If the message asks about relationships or connections between people, include "RELATIONSHIPS" in your providers list
|
|
185
|
-
- If the message asks about facts or specific information, include "FACTS" in your providers list
|
|
186
|
-
- If the message asks about the environment or world context, include "WORLD" in your providers list
|
|
187
|
-
- If no additional context is needed, you may leave the providers list empty.
|
|
217
|
+
You are analyzing a conversation to create a concise summary that captures the key points, topics, and important details.
|
|
188
218
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
- ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.
|
|
192
|
-
- If including inline code (short single words or function names), use single backticks (`) as appropriate.
|
|
193
|
-
- This ensures the user sees clearly formatted and copyable code when relevant.
|
|
219
|
+
# Recent Messages
|
|
220
|
+
{{recentMessages}}
|
|
194
221
|
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
# Instructions
|
|
223
|
+
Generate a summary that:
|
|
224
|
+
1. Captures the main topics discussed
|
|
225
|
+
2. Highlights key information shared
|
|
226
|
+
3. Notes any decisions made or questions asked
|
|
227
|
+
4. Maintains context for future reference
|
|
228
|
+
5. Is concise but comprehensive
|
|
197
229
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
230
|
+
**IMPORTANT**: Keep the summary under 2500 tokens. Be comprehensive but concise.
|
|
231
|
+
|
|
232
|
+
Also extract:
|
|
233
|
+
- **Topics**: List of main topics discussed (comma-separated)
|
|
234
|
+
- **Key Points**: Important facts or decisions (bullet points)
|
|
235
|
+
|
|
236
|
+
Respond in TOON:
|
|
237
|
+
text: Your comprehensive summary here
|
|
238
|
+
topics[0]: topic1
|
|
239
|
+
topics[1]: topic2
|
|
240
|
+
topics[2]: topic3
|
|
241
|
+
keyPoints[0]: First key point
|
|
242
|
+
keyPoints[1]: Second key point"""
|
|
243
|
+
|
|
244
|
+
LONG_TERM_EXTRACTION_TEMPLATE = """# Task: Extract Long-Term Memory (Strict Criteria)
|
|
245
|
+
|
|
246
|
+
You are analyzing a conversation to extract ONLY the most critical, persistent information about the user using cognitive science memory categories.
|
|
205
247
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
248
|
+
# Recent Messages
|
|
249
|
+
{{recentMessages}}
|
|
250
|
+
|
|
251
|
+
# Current Long-Term Memories
|
|
252
|
+
{{existingMemories}}
|
|
253
|
+
|
|
254
|
+
# Memory Categories (Based on Cognitive Science)
|
|
255
|
+
|
|
256
|
+
## 1. EPISODIC Memory
|
|
257
|
+
Personal experiences and specific events with temporal/spatial context.
|
|
258
|
+
**Examples:**
|
|
259
|
+
- "User completed migration project from MongoDB to PostgreSQL in Q2 2024"
|
|
260
|
+
- "User encountered authentication bug in production on March 15th"
|
|
261
|
+
- "User had a negative experience with Docker networking in previous job"
|
|
262
|
+
|
|
263
|
+
**Requirements:**
|
|
264
|
+
- Must include WHO did WHAT, WHEN/WHERE
|
|
265
|
+
- Must be a specific, concrete event (not a pattern)
|
|
266
|
+
- Must have significant impact or relevance to future work
|
|
267
|
+
|
|
268
|
+
## 2. SEMANTIC Memory
|
|
269
|
+
General facts, concepts, knowledge, and established truths about the user.
|
|
270
|
+
**Examples:**
|
|
271
|
+
- "User is a senior backend engineer with 8 years experience"
|
|
272
|
+
- "User specializes in distributed systems and microservices architecture"
|
|
273
|
+
- "User's primary programming language is TypeScript"
|
|
274
|
+
- "User works at Acme Corp as technical lead"
|
|
275
|
+
|
|
276
|
+
**Requirements:**
|
|
277
|
+
- Must be factual, timeless information
|
|
278
|
+
- Must be explicitly stated or demonstrated conclusively
|
|
279
|
+
- No speculation or inference from single instances
|
|
280
|
+
- Core identity, expertise, or knowledge only
|
|
281
|
+
|
|
282
|
+
## 3. PROCEDURAL Memory
|
|
283
|
+
Skills, workflows, methodologies, and how-to knowledge.
|
|
284
|
+
**Examples:**
|
|
285
|
+
- "User follows strict TDD workflow: write tests first, then implementation"
|
|
286
|
+
- "User prefers git rebase over merge to maintain linear history"
|
|
287
|
+
- "User's debugging process: check logs → reproduce locally → binary search"
|
|
288
|
+
- "User always writes JSDoc comments before implementing functions"
|
|
289
|
+
|
|
290
|
+
**Requirements:**
|
|
291
|
+
- Must describe HOW user does something
|
|
292
|
+
- Must be a repeated, consistent pattern (seen 3+ times or explicitly stated as standard practice)
|
|
293
|
+
- Must be a workflow, methodology, or skill application
|
|
294
|
+
- Not one-off preferences
|
|
295
|
+
|
|
296
|
+
# ULTRA-STRICT EXTRACTION CRITERIA
|
|
297
|
+
|
|
298
|
+
## DO EXTRACT (Only These):
|
|
299
|
+
|
|
300
|
+
**EPISODIC:**
|
|
301
|
+
- Significant completed projects or milestones
|
|
302
|
+
- Important bugs, incidents, or problems encountered
|
|
303
|
+
- Major decisions made with lasting impact
|
|
304
|
+
- Formative experiences that shape future work
|
|
305
|
+
|
|
306
|
+
**SEMANTIC:**
|
|
307
|
+
- Professional identity (role, title, company)
|
|
308
|
+
- Core expertise and specializations (stated explicitly or demonstrated conclusively)
|
|
309
|
+
- Primary languages, frameworks, or tools (not exploratory use)
|
|
310
|
+
- Established facts about their work context
|
|
311
|
+
|
|
312
|
+
**PROCEDURAL:**
|
|
313
|
+
- Consistent workflows demonstrated 3+ times or explicitly stated
|
|
314
|
+
- Standard practices user always follows
|
|
315
|
+
- Methodology preferences with clear rationale
|
|
316
|
+
- Debugging, testing, or development processes
|
|
317
|
+
|
|
318
|
+
## NEVER EXTRACT:
|
|
319
|
+
|
|
320
|
+
- **One-time requests or tasks** (e.g., "can you generate an image", "help me debug this")
|
|
321
|
+
- **Casual conversations** without lasting significance
|
|
322
|
+
- **Exploratory questions** (e.g., "how does X work?")
|
|
323
|
+
- **Temporary context** (current bug, today's task)
|
|
324
|
+
- **Preferences from single occurrence** (e.g., user asked for code once)
|
|
325
|
+
- **Social pleasantries** (thank you, greetings)
|
|
326
|
+
- **Testing or experimentation** (trying out a feature)
|
|
327
|
+
- **Common patterns everyone has** (likes clear explanations)
|
|
328
|
+
- **Situational information** (working on feature X today)
|
|
329
|
+
- **Opinions without persistence** (single complaint, isolated praise)
|
|
330
|
+
- **General knowledge** (not specific to user)
|
|
331
|
+
|
|
332
|
+
# Quality Gates (ALL Must Pass)
|
|
333
|
+
|
|
334
|
+
1. **Significance Test**: Will this matter in 3+ months?
|
|
335
|
+
2. **Specificity Test**: Is this concrete and actionable?
|
|
336
|
+
3. **Evidence Test**: Is there strong evidence (3+ instances OR explicit self-identification)?
|
|
337
|
+
4. **Uniqueness Test**: Is this specific to THIS user (not generic)?
|
|
338
|
+
5. **Confidence Test**: Confidence must be >= 0.85 (be VERY conservative)
|
|
339
|
+
6. **Non-Redundancy Test**: Does this add NEW information not in existing memories?
|
|
340
|
+
|
|
341
|
+
# Confidence Scoring (Be Conservative)
|
|
342
|
+
|
|
343
|
+
- **0.95-1.0**: User explicitly stated as core identity/practice AND demonstrated multiple times
|
|
344
|
+
- **0.85-0.94**: User explicitly stated OR consistently demonstrated 5+ times
|
|
345
|
+
- **0.75-0.84**: Strong pattern (3-4 instances) with supporting context
|
|
346
|
+
- **Below 0.75**: DO NOT EXTRACT (insufficient evidence)
|
|
347
|
+
|
|
348
|
+
# Critical Instructions
|
|
349
|
+
|
|
350
|
+
1. **Default to NOT extracting** - When in doubt, skip it
|
|
351
|
+
2. **Require overwhelming evidence** - One or two mentions is NOT enough
|
|
352
|
+
3. **Focus on what's PERSISTENT** - Not what's temporary or situational
|
|
353
|
+
4. **Verify against existing memories** - Don't duplicate or contradict
|
|
354
|
+
5. **Maximum 2-3 extractions per run** - Quality over quantity
|
|
355
|
+
|
|
356
|
+
**If there are no qualifying facts (which is common), return no memories entries.**
|
|
357
|
+
|
|
358
|
+
# Response Format
|
|
359
|
+
|
|
360
|
+
memories[0]:
|
|
361
|
+
category: semantic
|
|
362
|
+
content: User is a senior TypeScript developer with 8 years of backend experience
|
|
363
|
+
confidence: 0.95
|
|
364
|
+
memories[1]:
|
|
365
|
+
category: procedural
|
|
366
|
+
content: User follows TDD workflow: writes tests before implementation, runs tests after each change
|
|
367
|
+
confidence: 0.88
|
|
368
|
+
memories[2]:
|
|
369
|
+
category: episodic
|
|
370
|
+
content: User led database migration from MongoDB to PostgreSQL for payment system in Q2 2024
|
|
371
|
+
confidence: 0.92"""
|
|
372
|
+
|
|
373
|
+
MESSAGE_CLASSIFIER_TEMPLATE = """Analyze this user request and classify it for planning purposes:
|
|
374
|
+
|
|
375
|
+
"{{text}}"
|
|
376
|
+
|
|
377
|
+
Classify the request across these dimensions:
|
|
378
|
+
|
|
379
|
+
1. COMPLEXITY LEVEL:
|
|
380
|
+
- simple: Direct actions that don't require planning
|
|
381
|
+
- medium: Multi-step tasks requiring coordination
|
|
382
|
+
- complex: Strategic initiatives with multiple stakeholders
|
|
383
|
+
- enterprise: Large-scale transformations with full complexity
|
|
384
|
+
|
|
385
|
+
2. PLANNING TYPE:
|
|
386
|
+
- direct_action: Single action, no planning needed
|
|
387
|
+
- sequential_planning: Multiple steps in sequence
|
|
388
|
+
- strategic_planning: Complex coordination with stakeholders
|
|
389
|
+
|
|
390
|
+
3. REQUIRED CAPABILITIES:
|
|
391
|
+
- List specific capabilities needed (analysis, communication, project_management, etc.)
|
|
392
|
+
|
|
393
|
+
4. STAKEHOLDERS:
|
|
394
|
+
- List types of people/groups involved
|
|
395
|
+
|
|
396
|
+
5. CONSTRAINTS:
|
|
397
|
+
- List limitations or requirements mentioned
|
|
398
|
+
|
|
399
|
+
6. DEPENDENCIES:
|
|
400
|
+
- List dependencies between tasks or external factors
|
|
401
|
+
|
|
402
|
+
Respond in this exact format:
|
|
403
|
+
COMPLEXITY: [simple|medium|complex|enterprise]
|
|
404
|
+
PLANNING: [direct_action|sequential_planning|strategic_planning]
|
|
405
|
+
CAPABILITIES: [comma-separated list]
|
|
406
|
+
STAKEHOLDERS: [comma-separated list]
|
|
407
|
+
CONSTRAINTS: [comma-separated list]
|
|
408
|
+
DEPENDENCIES: [comma-separated list]
|
|
409
|
+
CONFIDENCE: [0.0-1.0]"""
|
|
410
|
+
|
|
411
|
+
MESSAGE_HANDLER_TEMPLATE = """task: Generate dialog and actions for {{agentName}}.
|
|
412
|
+
|
|
413
|
+
context:
|
|
414
|
+
{{providers}}
|
|
209
415
|
|
|
210
|
-
|
|
416
|
+
rules[12]:
|
|
417
|
+
- think briefly, then respond
|
|
418
|
+
- always include a <thought> field, even for direct replies
|
|
419
|
+
- actions execute in listed order
|
|
420
|
+
- if replying without another grounded state/action query, REPLY goes first
|
|
421
|
+
- use IGNORE or STOP only by themselves
|
|
422
|
+
- in group conversations, choose IGNORE if the latest message is addressed to someone else and not to {{agentName}}
|
|
423
|
+
- include providers only when needed
|
|
424
|
+
- use provider_hints from context when present instead of restating the same rules
|
|
425
|
+
- if an action needs inputs, include them inside that action's <params> block
|
|
426
|
+
- if a required param is unknown, ask for clarification in text
|
|
427
|
+
- for live status questions or remaining-work queries, do not answer from recent conversation alone; call the relevant action/provider to refresh state, and do not pair it with a speculative REPLY that guesses the result
|
|
428
|
+
- when an action will fetch the state and produce the final grounded answer, do not add REPLY just to say "checking", "let me look", or similar filler; use the action alone and leave text empty
|
|
429
|
+
- for LifeOps create requests with a clear defaultable habit or natural window, such as drinking water, stretch breaks during the day, weekday-after-lunch Invisalign checks, or brushing when waking up and before bed, call LIFE instead of asking for exact clock times unless the user explicitly asks for precise scheduling
|
|
430
|
+
|
|
431
|
+
control_actions:
|
|
432
|
+
- STOP means the task is done and the agent should end the run without executing more actions
|
|
433
|
+
- STOP is a terminal control action even if it is not listed in available actions
|
|
434
|
+
|
|
435
|
+
fields[5]{name,meaning}:
|
|
436
|
+
- thought | short plan
|
|
437
|
+
- actions | ordered <action> entries inside <actions>
|
|
438
|
+
- providers | array of provider names, or empty
|
|
439
|
+
- text | next message for {{agentName}}
|
|
440
|
+
- simple | true or false
|
|
441
|
+
|
|
442
|
+
formatting:
|
|
443
|
+
- wrap multi-line code in fenced code blocks
|
|
444
|
+
- use inline backticks for short code identifiers
|
|
445
|
+
|
|
446
|
+
output:
|
|
447
|
+
XML only. Return exactly one <response>...</response> document. No prose before or after it. No <think>.
|
|
448
|
+
|
|
449
|
+
Example:
|
|
211
450
|
<response>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
<
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
</params>
|
|
225
|
-
</response>
|
|
226
|
-
|
|
227
|
-
The <params> block is optional - only include when actions require input parameters.
|
|
228
|
-
If an action has no parameters or you're only using REPLY/IGNORE, omit <params> entirely.
|
|
229
|
-
|
|
230
|
-
IMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.
|
|
231
|
-
</output>"""
|
|
232
|
-
|
|
233
|
-
MULTI_STEP_DECISION_TEMPLATE = """<task>
|
|
234
|
-
Determine the next step the assistant should take in this conversation to help the user reach their goal.
|
|
235
|
-
</task>
|
|
451
|
+
<thought>Reply briefly. No extra providers needed.</thought>
|
|
452
|
+
<actions>
|
|
453
|
+
<action>
|
|
454
|
+
<name>REPLY</name>
|
|
455
|
+
</action>
|
|
456
|
+
</actions>
|
|
457
|
+
<providers></providers>
|
|
458
|
+
<text>Your message here</text>
|
|
459
|
+
<simple>true</simple>
|
|
460
|
+
</response>"""
|
|
461
|
+
|
|
462
|
+
MULTI_STEP_DECISION_TEMPLATE = """Determine the next step the assistant should take in this conversation to help the user reach their goal.
|
|
236
463
|
|
|
237
464
|
{{recentMessages}}
|
|
238
465
|
|
|
@@ -258,27 +485,21 @@ These are the actions or data provider calls that have already been used in this
|
|
|
258
485
|
|
|
259
486
|
{{actionResults}}
|
|
260
487
|
|
|
261
|
-
|
|
488
|
+
keys:
|
|
262
489
|
"thought" Clearly explain your reasoning for the selected providers and/or action, and how this step contributes to resolving the user's request.
|
|
263
490
|
"action" Name of the action to execute after providers return (can be empty if no action is needed).
|
|
264
491
|
"providers" List of provider names to call in this step (can be empty if none are needed).
|
|
265
492
|
"isFinish" Set to true only if the task is fully complete.
|
|
266
|
-
</keys>
|
|
267
493
|
|
|
268
494
|
⚠️ IMPORTANT: Do **not** mark the task as `isFinish: true` immediately after calling an action. Wait for the action to complete before deciding the task is finished.
|
|
269
495
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
<isFinish>true | false</isFinish>
|
|
276
|
-
</response>
|
|
277
|
-
</output>"""
|
|
496
|
+
output:
|
|
497
|
+
thought: Your thought here
|
|
498
|
+
action: ACTION
|
|
499
|
+
providers[2]: PROVIDER1,PROVIDER2
|
|
500
|
+
isFinish: false"""
|
|
278
501
|
|
|
279
|
-
MULTI_STEP_SUMMARY_TEMPLATE = """
|
|
280
|
-
Summarize what the assistant has done so far and provide a final response to the user based on the completed steps.
|
|
281
|
-
</task>
|
|
502
|
+
MULTI_STEP_SUMMARY_TEMPLATE = """Summarize what the assistant has done so far and provide a final response to the user based on the completed steps.
|
|
282
503
|
|
|
283
504
|
# Context Information
|
|
284
505
|
{{bio}}
|
|
@@ -306,13 +527,10 @@ Here are the actions taken by the assistant to fulfill the request:
|
|
|
306
527
|
|
|
307
528
|
- Review the execution trace and last reasoning step carefully
|
|
308
529
|
|
|
309
|
-
- Your final output MUST be in this
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
<text>Your final message to the user</text>
|
|
314
|
-
</response>
|
|
315
|
-
</output>"""
|
|
530
|
+
- Your final output MUST be TOON in this format:
|
|
531
|
+
output:
|
|
532
|
+
thought: Your thought here
|
|
533
|
+
text: Your final message to the user"""
|
|
316
534
|
|
|
317
535
|
OPTION_EXTRACTION_TEMPLATE = """# Task: Extract selected task and option from user message
|
|
318
536
|
|
|
@@ -328,40 +546,66 @@ OPTION_EXTRACTION_TEMPLATE = """# Task: Extract selected task and option from us
|
|
|
328
546
|
3. Return the task ID (shortened UUID) and selected option name exactly as listed above
|
|
329
547
|
4. If no clear selection is made, return null for both fields
|
|
330
548
|
|
|
331
|
-
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
332
|
-
Go directly to the XML response format without any preamble or explanation.
|
|
333
549
|
|
|
334
|
-
Return in
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
550
|
+
Return in TOON format:
|
|
551
|
+
taskId: string_or_null
|
|
552
|
+
selectedOption: OPTION_NAME_or_null
|
|
553
|
+
|
|
554
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
|
|
555
|
+
|
|
556
|
+
POST_ACTION_DECISION_TEMPLATE = """Continue helping the user after reviewing the latest action results.
|
|
557
|
+
|
|
558
|
+
context:
|
|
559
|
+
{{providers}}
|
|
560
|
+
|
|
561
|
+
recent conversation:
|
|
562
|
+
{{recentMessages}}
|
|
563
|
+
|
|
564
|
+
recent action results:
|
|
565
|
+
{{actionResults}}
|
|
339
566
|
|
|
340
|
-
|
|
567
|
+
latest reflection task status:
|
|
568
|
+
{{taskCompletionStatus}}
|
|
569
|
+
|
|
570
|
+
rules[10]:
|
|
571
|
+
- think briefly, then continue the task from the latest action results
|
|
572
|
+
- actions execute in listed order
|
|
573
|
+
- if replying, REPLY goes first
|
|
574
|
+
- use IGNORE or STOP only by themselves
|
|
575
|
+
- include providers only when needed
|
|
576
|
+
- use provider_hints from context when present instead of restating the same rules
|
|
577
|
+
- if an action needs inputs, include them under params keyed by action name
|
|
578
|
+
- if a required param is unknown, ask for clarification in text
|
|
579
|
+
- if reflection says the task is incomplete, keep working or explain the concrete follow-up you still need
|
|
580
|
+
- if the task is complete, either reply to the user or use STOP to end the run
|
|
581
|
+
- STOP is a terminal control action even if it is not listed in available actions
|
|
582
|
+
|
|
583
|
+
output:
|
|
584
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
585
|
+
|
|
586
|
+
thought: Your thought here
|
|
587
|
+
actions[1]: ACTION
|
|
588
|
+
providers[0]:
|
|
589
|
+
text: Your message here
|
|
590
|
+
simple: true"""
|
|
341
591
|
|
|
342
592
|
POST_CREATION_TEMPLATE = """# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.
|
|
343
593
|
|
|
344
594
|
Example task outputs:
|
|
345
595
|
1. A post about the importance of AI in our lives
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
<imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>
|
|
350
|
-
</response>
|
|
596
|
+
thought: I am thinking about writing a post about the importance of AI in our lives
|
|
597
|
+
post: AI is changing the world and it is important to understand how it works
|
|
598
|
+
imagePrompt: A futuristic cityscape with flying cars and people using AI to do things
|
|
351
599
|
|
|
352
600
|
2. A post about dogs
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
<imagePrompt>A dog playing with a ball in a park</imagePrompt>
|
|
357
|
-
</response>
|
|
601
|
+
thought: I am thinking about writing a post about dogs
|
|
602
|
+
post: Dogs are man's best friend and they are loyal and loving
|
|
603
|
+
imagePrompt: A dog playing with a ball in a park
|
|
358
604
|
|
|
359
605
|
3. A post about finding a new job
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
<imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>
|
|
364
|
-
</response>
|
|
606
|
+
thought: Getting a job is hard, I bet there's a good post in that
|
|
607
|
+
post: Just keep going!
|
|
608
|
+
imagePrompt: A person looking at a computer screen with a job search website
|
|
365
609
|
|
|
366
610
|
{{providers}}
|
|
367
611
|
|
|
@@ -369,21 +613,17 @@ Write a post that is {{adjective}} about {{topic}} (without mentioning {{topic}}
|
|
|
369
613
|
Your response should be 1, 2, or 3 sentences (choose the length at random).
|
|
370
614
|
Your response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.
|
|
371
615
|
|
|
372
|
-
Your output should be formatted
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
<imagePrompt>Optional image prompt here</imagePrompt>
|
|
377
|
-
</response>
|
|
616
|
+
Your output should be formatted as TOON like this:
|
|
617
|
+
thought: Your thought here
|
|
618
|
+
post: Your post text here
|
|
619
|
+
imagePrompt: Optional image prompt here
|
|
378
620
|
|
|
379
621
|
The "post" field should be the post you want to send. Do not including any thinking or internal reflection in the "post" field.
|
|
380
622
|
The "imagePrompt" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.
|
|
381
623
|
The "thought" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.
|
|
382
624
|
|
|
383
|
-
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
384
|
-
Go directly to the XML response format without any preamble or explanation.
|
|
385
625
|
|
|
386
|
-
IMPORTANT: Your response must ONLY contain the
|
|
626
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
|
|
387
627
|
|
|
388
628
|
REFLECTION_EVALUATOR_TEMPLATE = """# Task: Generate Agent Reflection, Extract Facts and Relationships
|
|
389
629
|
|
|
@@ -408,40 +648,49 @@ Message Sender: {{senderName}} (ID: {{senderId}})
|
|
|
408
648
|
# Known Facts:
|
|
409
649
|
{{knownFacts}}
|
|
410
650
|
|
|
651
|
+
# Latest Action Results:
|
|
652
|
+
{{actionResults}}
|
|
653
|
+
|
|
411
654
|
# Instructions:
|
|
412
655
|
1. Generate a self-reflective thought on the conversation about your performance and interaction quality.
|
|
413
|
-
2. Extract new facts from the conversation.
|
|
656
|
+
2. Extract only durable new facts from the conversation.
|
|
657
|
+
- Prefer facts about the current user/sender that will still matter in a week: identity, stable preferences, recurring collaborators, durable setup, long-term projects, or ongoing constraints.
|
|
658
|
+
- Do NOT extract temporary status updates, current debugging/work items, one-off session metrics, isolated praise/complaints, or facts that are only true right now.
|
|
659
|
+
- If a fact would feel stale, irrelevant, or surprising to store a week from now, skip it.
|
|
660
|
+
- When in doubt, omit the fact.
|
|
414
661
|
3. Identify and describe relationships between entities.
|
|
415
662
|
- The sourceEntityId is the UUID of the entity initiating the interaction.
|
|
416
663
|
- The targetEntityId is the UUID of the entity being interacted with.
|
|
417
664
|
- Relationships are one-direction, so a friendship would be two entity relationships where each entity is both the source and the target of the other.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
665
|
+
4. It is normal to return no facts when nothing durable was learned.
|
|
666
|
+
5. Always decide whether the user's task or request is actually complete right now.
|
|
667
|
+
- Set `task_completed: true` only if the user no longer needs additional action or follow-up from you in this turn.
|
|
668
|
+
- If you asked a clarifying question, an action failed, work is still pending, or you only partially completed the request, set `task_completed: false`.
|
|
669
|
+
6. Always include a short `task_completion_reason` grounded in the conversation and action results.
|
|
670
|
+
|
|
671
|
+
Output:
|
|
672
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
673
|
+
Do not output JSON, XML, Markdown fences, or commentary.
|
|
674
|
+
Use indexed TOON fields exactly like this:
|
|
675
|
+
thought: "a self-reflective thought on the conversation"
|
|
676
|
+
task_completed: false
|
|
677
|
+
task_completion_reason: "The request is still incomplete because the needed action has not happened yet."
|
|
678
|
+
facts[0]:
|
|
679
|
+
claim: durable factual statement
|
|
680
|
+
type: fact
|
|
681
|
+
in_bio: false
|
|
682
|
+
already_known: false
|
|
683
|
+
relationships[0]:
|
|
684
|
+
sourceEntityId: entity_initiating_interaction
|
|
685
|
+
targetEntityId: entity_being_interacted_with
|
|
686
|
+
tags[0]: dm_interaction
|
|
687
|
+
|
|
688
|
+
For additional entries, increment the index: facts[1], relationships[1], tags[1], etc.
|
|
689
|
+
Always include `task_completed` and `task_completion_reason`.
|
|
690
|
+
If there are no durable new facts, omit all facts[...] entries.
|
|
691
|
+
If there are no relationships, omit all relationships[...] entries.
|
|
692
|
+
|
|
693
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
|
|
445
694
|
|
|
446
695
|
REFLECTION_TEMPLATE = """# Task: Reflect on recent agent behavior and interactions.
|
|
447
696
|
|
|
@@ -457,16 +706,35 @@ Analyze the agent's recent behavior and interactions. Consider:
|
|
|
457
706
|
3. Were any mistakes made?
|
|
458
707
|
4. What could be improved?
|
|
459
708
|
|
|
460
|
-
Respond using
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
709
|
+
Respond using TOON like this:
|
|
710
|
+
thought: Your detailed analysis
|
|
711
|
+
quality_score: Score 0-100 for overall quality
|
|
712
|
+
strengths: What went well
|
|
713
|
+
improvements: What could be improved
|
|
714
|
+
learnings: Key takeaways for future interactions
|
|
715
|
+
|
|
716
|
+
IMPORTANT: Your response must ONLY contain the TOON document above."""
|
|
717
|
+
|
|
718
|
+
REMOVE_CONTACT_TEMPLATE = """task: Extract the contact removal request.
|
|
719
|
+
|
|
720
|
+
context:
|
|
721
|
+
{{providers}}
|
|
468
722
|
|
|
469
|
-
|
|
723
|
+
current_message:
|
|
724
|
+
{{message}}
|
|
725
|
+
|
|
726
|
+
instructions[4]:
|
|
727
|
+
- identify the contact name to remove
|
|
728
|
+
- set confirmed to yes only when the user explicitly confirms removal
|
|
729
|
+
- set confirmed to no when confirmation is absent or ambiguous
|
|
730
|
+
- return only the requested contact
|
|
731
|
+
|
|
732
|
+
output:
|
|
733
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
734
|
+
|
|
735
|
+
Example:
|
|
736
|
+
contactName: Jane Doe
|
|
737
|
+
confirmed: yes"""
|
|
470
738
|
|
|
471
739
|
REPLY_TEMPLATE = """# Task: Generate dialog for the character {{agentName}}.
|
|
472
740
|
|
|
@@ -483,49 +751,281 @@ IMPORTANT CODE BLOCK FORMATTING RULES:
|
|
|
483
751
|
- This ensures the user sees clearly formatted and copyable code when relevant.
|
|
484
752
|
|
|
485
753
|
Do NOT include any thinking, reasoning, or <think> sections in your response.
|
|
486
|
-
Go directly to the
|
|
754
|
+
Go directly to the TOON response format without any preamble or explanation.
|
|
487
755
|
|
|
488
|
-
Respond using
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
<text>Your message here</text>
|
|
492
|
-
</response>
|
|
756
|
+
Respond using TOON like this:
|
|
757
|
+
thought: Your thought here
|
|
758
|
+
text: Your message here
|
|
493
759
|
|
|
494
|
-
IMPORTANT: Your response must ONLY contain the
|
|
760
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
|
|
495
761
|
|
|
496
|
-
|
|
762
|
+
SCHEDULE_FOLLOW_UP_TEMPLATE = """task: Extract follow-up scheduling information from the request.
|
|
497
763
|
|
|
498
|
-
|
|
764
|
+
context:
|
|
499
765
|
{{providers}}
|
|
500
|
-
</providers>
|
|
501
766
|
|
|
502
|
-
|
|
767
|
+
current_message:
|
|
768
|
+
{{message}}
|
|
503
769
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
- If someone uses a DIFFERENT name (not {{agentName}}) → IGNORE (they're talking to someone else)
|
|
507
|
-
- If you're actively participating in a conversation and the message continues that thread → RESPOND
|
|
508
|
-
- If someone tells you to stop or be quiet → STOP
|
|
509
|
-
- Otherwise → IGNORE
|
|
770
|
+
current_datetime:
|
|
771
|
+
{{currentDateTime}}
|
|
510
772
|
|
|
511
|
-
|
|
512
|
-
-
|
|
513
|
-
-
|
|
514
|
-
|
|
773
|
+
instructions[5]:
|
|
774
|
+
- identify who to follow up with
|
|
775
|
+
- include entityId only when it is explicitly known
|
|
776
|
+
- convert requested timing into an ISO datetime in scheduledAt
|
|
777
|
+
- normalize priority to high, medium, or low
|
|
778
|
+
- include message only when the user asked for a specific note or reminder text
|
|
515
779
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
Go directly to the XML response format without any preamble or explanation.
|
|
780
|
+
output:
|
|
781
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
519
782
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
783
|
+
Example:
|
|
784
|
+
contactName: Jane Doe
|
|
785
|
+
entityId:
|
|
786
|
+
scheduledAt: 2026-04-06T14:00:00.000Z
|
|
787
|
+
reason: Check in on the proposal
|
|
788
|
+
priority: medium
|
|
789
|
+
message: Send the latest deck before the call"""
|
|
790
|
+
|
|
791
|
+
SEARCH_CONTACTS_TEMPLATE = """task: Extract contact search criteria from the request.
|
|
792
|
+
|
|
793
|
+
context:
|
|
794
|
+
{{providers}}
|
|
795
|
+
|
|
796
|
+
current_message:
|
|
797
|
+
{{message}}
|
|
798
|
+
|
|
799
|
+
instructions[5]:
|
|
800
|
+
- return categories as a comma-separated list when the user filters by category
|
|
801
|
+
- return tags as a comma-separated list when the user filters by tags
|
|
802
|
+
- return searchTerm for any name or free-text lookup
|
|
803
|
+
- set intent to count when the user only wants a count, otherwise list
|
|
804
|
+
- omit fields that are not clearly requested
|
|
805
|
+
|
|
806
|
+
output:
|
|
807
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
808
|
+
|
|
809
|
+
Example:
|
|
810
|
+
categories: vip,colleague
|
|
811
|
+
searchTerm: Jane
|
|
812
|
+
tags: ai,design
|
|
813
|
+
intent: list"""
|
|
814
|
+
|
|
815
|
+
SHOULD_FOLLOW_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should follow this room.
|
|
816
|
+
|
|
817
|
+
context:
|
|
818
|
+
{{providers}}
|
|
819
|
+
|
|
820
|
+
current_message:
|
|
821
|
+
{{message}}
|
|
822
|
+
|
|
823
|
+
instructions[3]:
|
|
824
|
+
- return true only when the user is clearly asking {{agentName}} to follow, join, listen to, or stay engaged in this room
|
|
825
|
+
- return false when the request is ambiguous or unrelated
|
|
826
|
+
- prefer false when uncertain
|
|
827
|
+
|
|
828
|
+
output:
|
|
829
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
830
|
+
|
|
831
|
+
Example:
|
|
832
|
+
decision: true"""
|
|
833
|
+
|
|
834
|
+
SHOULD_MUTE_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should mute this room.
|
|
835
|
+
|
|
836
|
+
context:
|
|
837
|
+
{{providers}}
|
|
838
|
+
|
|
839
|
+
current_message:
|
|
840
|
+
{{message}}
|
|
841
|
+
|
|
842
|
+
instructions[3]:
|
|
843
|
+
- return true only when the user is clearly asking {{agentName}} to mute, silence, or ignore this room
|
|
844
|
+
- return false when the request is ambiguous or unrelated
|
|
845
|
+
- prefer false when uncertain
|
|
846
|
+
|
|
847
|
+
output:
|
|
848
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
849
|
+
|
|
850
|
+
Example:
|
|
851
|
+
decision: true"""
|
|
852
|
+
|
|
853
|
+
SHOULD_RESPOND_TEMPLATE = """task: Decide whether {{agentName}} should respond, ignore, or stop.
|
|
854
|
+
|
|
855
|
+
context:
|
|
856
|
+
{{providers}}
|
|
857
|
+
|
|
858
|
+
rules[7]:
|
|
859
|
+
- direct mention of {{agentName}} -> RESPOND
|
|
860
|
+
- different assistant name or talking to someone else -> IGNORE unless {{agentName}} is also directly addressed
|
|
861
|
+
- prior participation by {{agentName}} in the thread is not enough by itself; the newest message must still clearly expect {{agentName}} -> otherwise IGNORE
|
|
862
|
+
- request to stop or be quiet directed at {{agentName}} -> STOP
|
|
863
|
+
- if multiple people are mentioned and {{agentName}} is one of the addressees -> RESPOND
|
|
864
|
+
- in group conversations, if the latest message is addressed to someone else and not to {{agentName}}, IGNORE
|
|
865
|
+
- if unsure whether the speaker is talking to {{agentName}}, prefer IGNORE over hallucinating relevance
|
|
866
|
+
|
|
867
|
+
available_contexts:
|
|
868
|
+
{{availableContexts}}
|
|
869
|
+
|
|
870
|
+
context_routing:
|
|
871
|
+
- primaryContext: choose one context from available_contexts, or "general" if none apply
|
|
872
|
+
- secondaryContexts: optional comma-separated list of additional relevant contexts
|
|
873
|
+
- evidenceTurnIds: optional comma-separated list of message IDs supporting the decision
|
|
874
|
+
|
|
875
|
+
decision_note:
|
|
876
|
+
- respond only when the latest message is talking TO {{agentName}}
|
|
877
|
+
- talking TO {{agentName}} means name mention, reply chain, or a clear follow-up that still expects {{agentName}} to answer
|
|
878
|
+
- mentions of other people do not cancel a direct address to {{agentName}}
|
|
879
|
+
- casual conversation between other users is not enough
|
|
880
|
+
- if another assistant already answered and nobody re-addressed {{agentName}}, IGNORE
|
|
881
|
+
- if {{agentName}} already replied recently and nobody re-addressed {{agentName}}, IGNORE
|
|
882
|
+
- talking ABOUT {{agentName}} or continuing a room conversation around them is not enough
|
|
883
|
+
|
|
884
|
+
output:
|
|
885
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
886
|
+
|
|
887
|
+
Example:
|
|
888
|
+
name: {{agentName}}
|
|
889
|
+
reasoning: Direct mention and clear follow-up.
|
|
890
|
+
action: RESPOND
|
|
891
|
+
primaryContext: general
|
|
892
|
+
secondaryContexts:
|
|
893
|
+
evidenceTurnIds:"""
|
|
894
|
+
|
|
895
|
+
SHOULD_RESPOND_WITH_CONTEXT_TEMPLATE = """task: Decide whether {{agentName}} should respond and which domain context applies.
|
|
896
|
+
|
|
897
|
+
context:
|
|
898
|
+
{{providers}}
|
|
899
|
+
|
|
900
|
+
available_contexts:
|
|
901
|
+
{{availableContexts}}
|
|
902
|
+
|
|
903
|
+
rules[7]:
|
|
904
|
+
- direct mention of {{agentName}} -> RESPOND
|
|
905
|
+
- different assistant name or talking to someone else -> IGNORE unless {{agentName}} is also directly addressed
|
|
906
|
+
- prior participation by {{agentName}} in the thread is not enough by itself; the newest message must still clearly expect {{agentName}} -> otherwise IGNORE
|
|
907
|
+
- request to stop or be quiet directed at {{agentName}} -> STOP
|
|
908
|
+
- if multiple people are mentioned and {{agentName}} is one of the addressees -> RESPOND
|
|
909
|
+
- in group conversations, if the latest message is addressed to someone else and not to {{agentName}}, IGNORE
|
|
910
|
+
- if unsure whether the speaker is talking to {{agentName}}, prefer IGNORE over hallucinating relevance
|
|
911
|
+
|
|
912
|
+
context_routing:
|
|
913
|
+
- primaryContext: the single best-matching domain from available_contexts
|
|
914
|
+
- secondaryContexts: zero or more additional domains that are relevant
|
|
915
|
+
- action intent does not only come from the last message; consider the full recent conversation
|
|
916
|
+
- if no specific domain applies, use "general"
|
|
917
|
+
|
|
918
|
+
decision_note:
|
|
919
|
+
- respond only when the latest message is talking TO {{agentName}}
|
|
920
|
+
- talking TO {{agentName}} means name mention, reply chain, or a clear follow-up that still expects {{agentName}} to answer
|
|
921
|
+
- mentions of other people do not cancel a direct address to {{agentName}}
|
|
922
|
+
- casual conversation between other users is not enough
|
|
923
|
+
- if another assistant already answered and nobody re-addressed {{agentName}}, IGNORE
|
|
924
|
+
- if {{agentName}} already replied recently and nobody re-addressed {{agentName}}, IGNORE
|
|
925
|
+
- talking ABOUT {{agentName}} or continuing a room conversation around them is not enough
|
|
926
|
+
- context routing always applies, even for IGNORE/STOP decisions
|
|
927
|
+
|
|
928
|
+
output:
|
|
929
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
930
|
+
|
|
931
|
+
Example:
|
|
932
|
+
name: {{agentName}}
|
|
933
|
+
reasoning: Direct mention asking about token balance.
|
|
934
|
+
action: RESPOND
|
|
935
|
+
primaryContext: wallet
|
|
936
|
+
secondaryContexts: []"""
|
|
937
|
+
|
|
938
|
+
SHOULD_UNFOLLOW_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should unfollow this room.
|
|
939
|
+
|
|
940
|
+
context:
|
|
941
|
+
{{providers}}
|
|
942
|
+
|
|
943
|
+
current_message:
|
|
944
|
+
{{message}}
|
|
945
|
+
|
|
946
|
+
instructions[3]:
|
|
947
|
+
- return true only when the user is clearly asking {{agentName}} to stop following or leave this room
|
|
948
|
+
- return false when the request is ambiguous or unrelated
|
|
949
|
+
- prefer false when uncertain
|
|
950
|
+
|
|
951
|
+
output:
|
|
952
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
953
|
+
|
|
954
|
+
Example:
|
|
955
|
+
decision: true"""
|
|
956
|
+
|
|
957
|
+
SHOULD_UNMUTE_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should unmute this room.
|
|
958
|
+
|
|
959
|
+
context:
|
|
960
|
+
{{providers}}
|
|
526
961
|
|
|
527
|
-
|
|
528
|
-
|
|
962
|
+
current_message:
|
|
963
|
+
{{message}}
|
|
964
|
+
|
|
965
|
+
instructions[3]:
|
|
966
|
+
- return true only when the user is clearly asking {{agentName}} to unmute or resume listening to this room
|
|
967
|
+
- return false when the request is ambiguous or unrelated
|
|
968
|
+
- prefer false when uncertain
|
|
969
|
+
|
|
970
|
+
output:
|
|
971
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
972
|
+
|
|
973
|
+
Example:
|
|
974
|
+
decision: true"""
|
|
975
|
+
|
|
976
|
+
THINK_TEMPLATE = """# Task: Think deeply and reason carefully for {{agentName}}.
|
|
977
|
+
|
|
978
|
+
{{providers}}
|
|
979
|
+
|
|
980
|
+
# Context
|
|
981
|
+
The initial planning phase identified this question as requiring deeper analysis.
|
|
982
|
+
The following is the conversation so far and all available context.
|
|
983
|
+
|
|
984
|
+
# Instructions
|
|
985
|
+
You are {{agentName}}. A question or request has been identified as complex, ambiguous, or requiring careful reasoning. Your job is to think through this thoroughly before responding.
|
|
986
|
+
|
|
987
|
+
Approach this systematically:
|
|
988
|
+
1. Identify the core question or problem being asked
|
|
989
|
+
2. Consider multiple angles, approaches, or interpretations
|
|
990
|
+
3. Evaluate trade-offs, risks, and constraints
|
|
991
|
+
4. Draw on relevant knowledge and context from the conversation
|
|
992
|
+
5. Arrive at a well-reasoned conclusion or recommendation
|
|
993
|
+
|
|
994
|
+
Be thorough but concise. Prioritize depth of reasoning over length. If there are genuine unknowns, acknowledge them rather than guessing.
|
|
995
|
+
|
|
996
|
+
Respond using TOON:
|
|
997
|
+
thought: Your detailed internal reasoning — the full chain of thought, alternatives considered, and why you reached your conclusion
|
|
998
|
+
text: Your response to the user — clear, structured, and well-reasoned. Use headings, lists, or code blocks as appropriate for the content.
|
|
999
|
+
|
|
1000
|
+
IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any preamble or explanation outside of it."""
|
|
1001
|
+
|
|
1002
|
+
UPDATE_CONTACT_TEMPLATE = """task: Extract contact updates from the request.
|
|
1003
|
+
|
|
1004
|
+
context:
|
|
1005
|
+
{{providers}}
|
|
1006
|
+
|
|
1007
|
+
current_message:
|
|
1008
|
+
{{message}}
|
|
1009
|
+
|
|
1010
|
+
instructions[6]:
|
|
1011
|
+
- identify the contact name to update
|
|
1012
|
+
- set operation to replace unless the user clearly says to add_to or remove_from
|
|
1013
|
+
- return categories and tags as comma-separated lists
|
|
1014
|
+
- return preferences and customFields as comma-separated key:value pairs
|
|
1015
|
+
- include notes only when explicitly requested
|
|
1016
|
+
- omit fields that are not being changed
|
|
1017
|
+
|
|
1018
|
+
output:
|
|
1019
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
1020
|
+
|
|
1021
|
+
Example:
|
|
1022
|
+
contactName: Jane Doe
|
|
1023
|
+
operation: add_to
|
|
1024
|
+
categories: vip
|
|
1025
|
+
tags: ai,friend
|
|
1026
|
+
preferences: timezone:America/New_York,language:English
|
|
1027
|
+
customFields: company:Acme,title:Designer
|
|
1028
|
+
notes: Prefers async communication"""
|
|
529
1029
|
|
|
530
1030
|
UPDATE_ENTITY_TEMPLATE = """# Task: Update entity information.
|
|
531
1031
|
|
|
@@ -538,19 +1038,43 @@ UPDATE_ENTITY_TEMPLATE = """# Task: Update entity information.
|
|
|
538
1038
|
Based on the request, determine what information about the entity should be updated.
|
|
539
1039
|
Only update fields that the user has explicitly requested to change.
|
|
540
1040
|
|
|
541
|
-
Respond using
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
1041
|
+
Respond using TOON like this:
|
|
1042
|
+
thought: Your reasoning for the entity update
|
|
1043
|
+
entity_id: The entity ID to update
|
|
1044
|
+
updates[1]{name,value}:
|
|
1045
|
+
field_name,new_value
|
|
1046
|
+
|
|
1047
|
+
IMPORTANT: Your response must ONLY contain the TOON document above."""
|
|
1048
|
+
|
|
1049
|
+
UPDATE_ROLE_TEMPLATE = """task: Extract the requested role change.
|
|
1050
|
+
|
|
1051
|
+
context:
|
|
1052
|
+
{{providers}}
|
|
1053
|
+
|
|
1054
|
+
current_roles:
|
|
1055
|
+
{{roles}}
|
|
1056
|
+
|
|
1057
|
+
recent_messages:
|
|
1058
|
+
{{recentMessages}}
|
|
1059
|
+
|
|
1060
|
+
current_message:
|
|
1061
|
+
{{message}}
|
|
1062
|
+
|
|
1063
|
+
instructions[6]:
|
|
1064
|
+
- identify the single entity whose role should be updated
|
|
1065
|
+
- return entity_id only when the UUID is explicit in context
|
|
1066
|
+
- normalize new_role to one of OWNER, ADMIN, MEMBER, GUEST, or NONE
|
|
1067
|
+
- if the user is removing elevated access without naming a new role, use NONE
|
|
1068
|
+
- do not invent entity ids or roles
|
|
1069
|
+
- include a short thought describing the change
|
|
1070
|
+
|
|
1071
|
+
output:
|
|
1072
|
+
TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
|
|
1073
|
+
|
|
1074
|
+
Example:
|
|
1075
|
+
thought: Sarah should become an admin.
|
|
1076
|
+
entity_id: 00000000-0000-0000-0000-000000000000
|
|
1077
|
+
new_role: ADMIN"""
|
|
554
1078
|
|
|
555
1079
|
UPDATE_SETTINGS_TEMPLATE = """# Task: Update settings based on the request.
|
|
556
1080
|
|
|
@@ -563,39 +1087,84 @@ UPDATE_SETTINGS_TEMPLATE = """# Task: Update settings based on the request.
|
|
|
563
1087
|
Based on the request, determine which settings to update.
|
|
564
1088
|
Only update settings that the user has explicitly requested.
|
|
565
1089
|
|
|
566
|
-
Respond using
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
1090
|
+
Respond using TOON like this:
|
|
1091
|
+
thought: Your reasoning for the settings changes
|
|
1092
|
+
updates[1]{key,value}:
|
|
1093
|
+
setting_key,new_value
|
|
1094
|
+
|
|
1095
|
+
IMPORTANT: Your response must ONLY contain the TOON document above."""
|
|
1096
|
+
|
|
1097
|
+
UPDATE_SUMMARIZATION_TEMPLATE = """# Task: Update and Condense Conversation Summary
|
|
1098
|
+
|
|
1099
|
+
You are updating an existing conversation summary with new messages, while keeping the total summary concise.
|
|
576
1100
|
|
|
577
|
-
|
|
1101
|
+
# Existing Summary
|
|
1102
|
+
{{existingSummary}}
|
|
1103
|
+
|
|
1104
|
+
# Existing Topics
|
|
1105
|
+
{{existingTopics}}
|
|
1106
|
+
|
|
1107
|
+
# New Messages Since Last Summary
|
|
1108
|
+
{{newMessages}}
|
|
1109
|
+
|
|
1110
|
+
# Instructions
|
|
1111
|
+
Update the summary by:
|
|
1112
|
+
1. Merging the existing summary with insights from the new messages
|
|
1113
|
+
2. Removing redundant or less important details to stay under the token limit
|
|
1114
|
+
3. Keeping the most important context and decisions
|
|
1115
|
+
4. Adding new topics if they emerge
|
|
1116
|
+
5. **CRITICAL**: Keep the ENTIRE updated summary under 2500 tokens
|
|
1117
|
+
|
|
1118
|
+
The goal is a rolling summary that captures the essence of the conversation without growing indefinitely.
|
|
1119
|
+
|
|
1120
|
+
Respond in TOON:
|
|
1121
|
+
text: Your updated and condensed summary here
|
|
1122
|
+
topics[0]: topic1
|
|
1123
|
+
topics[1]: topic2
|
|
1124
|
+
topics[2]: topic3
|
|
1125
|
+
keyPoints[0]: First key point
|
|
1126
|
+
keyPoints[1]: Second key point"""
|
|
578
1127
|
|
|
579
1128
|
BOOLEAN_FOOTER = "Respond with only a YES or a NO."
|
|
580
1129
|
|
|
581
1130
|
__all__ = [
|
|
1131
|
+
"ADD_CONTACT_TEMPLATE",
|
|
582
1132
|
"AUTONOMY_CONTINUOUS_CONTINUE_TEMPLATE",
|
|
583
1133
|
"AUTONOMY_CONTINUOUS_FIRST_TEMPLATE",
|
|
584
1134
|
"AUTONOMY_TASK_CONTINUE_TEMPLATE",
|
|
585
1135
|
"AUTONOMY_TASK_FIRST_TEMPLATE",
|
|
586
1136
|
"CHOOSE_OPTION_TEMPLATE",
|
|
1137
|
+
"EXTRACT_SECRET_OPERATION_TEMPLATE",
|
|
1138
|
+
"EXTRACT_SECRET_REQUEST_TEMPLATE",
|
|
1139
|
+
"EXTRACT_SECRETS_TEMPLATE",
|
|
587
1140
|
"IMAGE_DESCRIPTION_TEMPLATE",
|
|
588
1141
|
"IMAGE_GENERATION_TEMPLATE",
|
|
1142
|
+
"INITIAL_SUMMARIZATION_TEMPLATE",
|
|
1143
|
+
"LONG_TERM_EXTRACTION_TEMPLATE",
|
|
1144
|
+
"MESSAGE_CLASSIFIER_TEMPLATE",
|
|
589
1145
|
"MESSAGE_HANDLER_TEMPLATE",
|
|
590
1146
|
"MULTI_STEP_DECISION_TEMPLATE",
|
|
591
1147
|
"MULTI_STEP_SUMMARY_TEMPLATE",
|
|
592
1148
|
"OPTION_EXTRACTION_TEMPLATE",
|
|
1149
|
+
"POST_ACTION_DECISION_TEMPLATE",
|
|
593
1150
|
"POST_CREATION_TEMPLATE",
|
|
594
1151
|
"REFLECTION_EVALUATOR_TEMPLATE",
|
|
595
1152
|
"REFLECTION_TEMPLATE",
|
|
1153
|
+
"REMOVE_CONTACT_TEMPLATE",
|
|
596
1154
|
"REPLY_TEMPLATE",
|
|
1155
|
+
"SCHEDULE_FOLLOW_UP_TEMPLATE",
|
|
1156
|
+
"SEARCH_CONTACTS_TEMPLATE",
|
|
1157
|
+
"SHOULD_FOLLOW_ROOM_TEMPLATE",
|
|
1158
|
+
"SHOULD_MUTE_ROOM_TEMPLATE",
|
|
597
1159
|
"SHOULD_RESPOND_TEMPLATE",
|
|
1160
|
+
"SHOULD_RESPOND_WITH_CONTEXT_TEMPLATE",
|
|
1161
|
+
"SHOULD_UNFOLLOW_ROOM_TEMPLATE",
|
|
1162
|
+
"SHOULD_UNMUTE_ROOM_TEMPLATE",
|
|
1163
|
+
"THINK_TEMPLATE",
|
|
1164
|
+
"UPDATE_CONTACT_TEMPLATE",
|
|
598
1165
|
"UPDATE_ENTITY_TEMPLATE",
|
|
1166
|
+
"UPDATE_ROLE_TEMPLATE",
|
|
599
1167
|
"UPDATE_SETTINGS_TEMPLATE",
|
|
1168
|
+
"UPDATE_SUMMARIZATION_TEMPLATE",
|
|
600
1169
|
"BOOLEAN_FOOTER",
|
|
601
1170
|
]
|