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