@elizaos/prompts 2.0.0-alpha.43 → 2.0.0-alpha.430

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