@elizaos/prompts 2.0.0-alpha.13 → 2.0.0-alpha.131

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 (35) hide show
  1. package/dist/python/prompts.py +574 -261
  2. package/dist/rust/prompts.rs +561 -262
  3. package/dist/typescript/index.d.ts +28 -0
  4. package/dist/typescript/index.ts +588 -261
  5. package/package.json +2 -2
  6. package/prompts/add_contact.txt +29 -0
  7. package/prompts/choose_option.txt +4 -7
  8. package/prompts/image_description.txt +8 -15
  9. package/prompts/image_generation.txt +4 -7
  10. package/prompts/message_classifier.txt +37 -0
  11. package/prompts/message_handler.txt +42 -95
  12. package/prompts/multi_step_decision.txt +6 -13
  13. package/prompts/multi_step_summary.txt +4 -10
  14. package/prompts/option_extraction.txt +4 -9
  15. package/prompts/post_action_decision.txt +35 -0
  16. package/prompts/post_creation.txt +14 -25
  17. package/prompts/reflection.txt +8 -11
  18. package/prompts/reflection_evaluator.txt +37 -32
  19. package/prompts/remove_contact.txt +20 -0
  20. package/prompts/reply.txt +5 -8
  21. package/prompts/schedule_follow_up.txt +28 -0
  22. package/prompts/search_contacts.txt +23 -0
  23. package/prompts/should_follow_room.txt +18 -0
  24. package/prompts/should_mute_room.txt +18 -0
  25. package/prompts/should_respond.txt +37 -37
  26. package/prompts/should_respond_with_context.txt +41 -0
  27. package/prompts/should_unfollow_room.txt +18 -0
  28. package/prompts/should_unmute_room.txt +18 -0
  29. package/prompts/think.txt +25 -0
  30. package/prompts/update_contact.txt +27 -0
  31. package/prompts/update_entity.txt +6 -13
  32. package/prompts/update_role.txt +29 -0
  33. package/prompts/update_settings.txt +5 -12
  34. package/scripts/generate-action-docs.js +12 -1
  35. package/scripts/generate-plugin-action-spec.js +1 -0
@@ -10,6 +10,36 @@ These prompts use Handlebars-style template syntax:
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
+ ADD_CONTACT_TEMPLATE = """task: Extract contact information to add to the relationships.
14
+
15
+ context:
16
+ {{providers}}
17
+
18
+ recent_messages:
19
+ {{recentMessages}}
20
+
21
+ current_message:
22
+ {{message}}
23
+
24
+ instructions[5]:
25
+ - identify the contact name being added
26
+ - include entityId only if it is explicitly known from context
27
+ - return categories as a comma-separated list
28
+ - include notes, timezone, and language only when clearly present
29
+ - include a short reason for why this contact should be saved
30
+
31
+ output:
32
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
33
+
34
+ Example:
35
+ contactName: Jane Doe
36
+ entityId:
37
+ categories: vip,colleague
38
+ notes: Met at the design summit
39
+ timezone: America/New_York
40
+ language: English
41
+ reason: Important collaborator to remember"""
42
+
13
43
  AUTONOMY_CONTINUOUS_CONTINUE_TEMPLATE = """Your job: reflect on context, decide what you want to do next, and act if appropriate.
14
44
  - Use available actions/tools when they can advance the goal.
15
45
  - Use thinking to think about and plan what you want to do.
@@ -84,38 +114,30 @@ CHOOSE_OPTION_TEMPLATE = """# Task: Choose an option from the available choices.
84
114
  Analyze the options and select the most appropriate one based on the current context.
85
115
  Provide your reasoning and the selected option ID.
86
116
 
87
- Respond using XML format like this:
88
- <response>
89
- <thought>Your reasoning for the selection</thought>
90
- <selected_id>The ID of the selected option</selected_id>
91
- </response>
117
+ Respond using TOON like this:
118
+ thought: Your reasoning for the selection
119
+ selected_id: The ID of the selected option
92
120
 
93
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above."""
121
+ IMPORTANT: Your response must ONLY contain the TOON document above."""
94
122
 
95
- IMAGE_DESCRIPTION_TEMPLATE = """<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>
123
+ IMAGE_DESCRIPTION_TEMPLATE = """Task: Analyze the provided image and generate a comprehensive description with multiple levels of detail.
96
124
 
97
- <instructions>
125
+ Instructions:
98
126
  Carefully examine the image and provide:
99
127
  1. A concise, descriptive title that captures the main subject or scene
100
128
  2. A brief summary description (1-2 sentences) highlighting the key elements
101
129
  3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details
102
130
 
103
131
  Be objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.
104
- </instructions>
105
132
 
106
- <output>
107
- Do NOT include any thinking, reasoning, or <think> sections in your response.
108
- Go directly to the XML response format without any preamble or explanation.
133
+ Output:
109
134
 
110
- Respond using XML format like this:
111
- <response>
112
- <title>A concise, descriptive title for the image</title>
113
- <description>A brief 1-2 sentence summary of the key elements in the image</description>
114
- <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>
115
- </response>
135
+ Respond using TOON like this:
136
+ title: A concise, descriptive title for the image
137
+ description: A brief 1-2 sentence summary of the key elements in the image
138
+ text: An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image
116
139
 
117
- 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>.
118
- </output>"""
140
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
119
141
 
120
142
  IMAGE_GENERATION_TEMPLATE = """# Task: Generate an image prompt for {{agentName}}.
121
143
 
@@ -128,111 +150,99 @@ The prompt should be specific, descriptive, and suitable for AI image generation
128
150
  # Recent conversation:
129
151
  {{recentMessages}}
130
152
 
131
- Respond using XML format like this:
132
- <response>
133
- <thought>Your reasoning for the image prompt</thought>
134
- <prompt>Detailed image generation prompt</prompt>
135
- </response>
153
+ Respond using TOON like this:
154
+ thought: Your reasoning for the image prompt
155
+ prompt: Detailed image generation prompt
136
156
 
137
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above."""
157
+ IMPORTANT: Your response must ONLY contain the TOON document above."""
138
158
 
139
- MESSAGE_HANDLER_TEMPLATE = """<task>Generate dialog and actions for the character {{agentName}}.</task>
159
+ MESSAGE_CLASSIFIER_TEMPLATE = """Analyze this user request and classify it for planning purposes:
140
160
 
141
- <providers>
142
- {{providers}}
143
- </providers>
144
-
145
- <instructions>
146
- Write a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.
147
-
148
- IMPORTANT ACTION ORDERING RULES:
149
- - Actions are executed in the ORDER you list them - the order MATTERS!
150
- - REPLY should come FIRST to acknowledge the user's request before executing other actions
151
- - Common patterns:
152
- - For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)
153
- - For task execution: REPLY,SEND_MESSAGE or REPLY,EVM_SWAP_TOKENS (acknowledge first, then do the task)
154
- - For multi-step operations: REPLY,ACTION1,ACTION2 (acknowledge first, then complete all steps)
155
- - REPLY is used to acknowledge and inform the user about what you're going to do
156
- - Follow-up actions execute the actual tasks after acknowledgment
157
- - Use IGNORE only when you should not respond at all
158
- - If you use IGNORE, do not include any other actions. IGNORE should be used alone when you should not respond or take any actions.
159
-
160
- IMPORTANT ACTION PARAMETERS:
161
- - Some actions accept input parameters that you should extract from the conversation
162
- - When an action has parameters listed in its description, include a <params> block for that action
163
- - Extract parameter values from the user's message and conversation context
164
- - Required parameters MUST be provided; optional parameters can be omitted if not mentioned
165
- - If you cannot determine a required parameter value, ask the user for clarification in your <text>
166
-
167
- EXAMPLE (action parameters):
168
- User message: "Send a message to @dev_guru on telegram saying Hello!"
169
- Actions: REPLY,SEND_MESSAGE
170
- Params:
171
- <params>
172
- <SEND_MESSAGE>
173
- <targetType>user</targetType>
174
- <source>telegram</source>
175
- <target>dev_guru</target>
176
- <text>Hello!</text>
177
- </SEND_MESSAGE>
178
- </params>
179
-
180
- IMPORTANT PROVIDER SELECTION RULES:
181
- - Only include providers if they are needed to respond accurately.
182
- - If the message mentions images, photos, pictures, attachments, or visual content, OR if you see "(Attachments:" in the conversation, you MUST include "ATTACHMENTS" in your providers list
183
- - If the message asks about or references specific people, include "ENTITIES" in your providers list
184
- - If the message asks about relationships or connections between people, include "RELATIONSHIPS" in your providers list
185
- - If the message asks about facts or specific information, include "FACTS" in your providers list
186
- - If the message asks about the environment or world context, include "WORLD" in your providers list
187
- - If no additional context is needed, you may leave the providers list empty.
161
+ "{{text}}"
188
162
 
189
- IMPORTANT CODE BLOCK FORMATTING RULES:
190
- - 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).
191
- - ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.
192
- - If including inline code (short single words or function names), use single backticks (`) as appropriate.
193
- - This ensures the user sees clearly formatted and copyable code when relevant.
163
+ Classify the request across these dimensions:
194
164
 
195
- 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.
196
- </instructions>
165
+ 1. COMPLEXITY LEVEL:
166
+ - simple: Direct actions that don't require planning
167
+ - medium: Multi-step tasks requiring coordination
168
+ - complex: Strategic initiatives with multiple stakeholders
169
+ - enterprise: Large-scale transformations with full complexity
197
170
 
198
- <keys>
199
- "thought" should be a short description of what the agent is thinking about and planning.
200
- "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)
201
- "providers" should be a comma-separated list of the providers that {{agentName}} will use to have the right context for responding and acting (NEVER use "IGNORE" as a provider - use specific provider names like ATTACHMENTS, ENTITIES, FACTS, KNOWLEDGE, etc.)
202
- "text" should be the text of the next message for {{agentName}} which they will send to the conversation.
203
- "params" (optional) should contain action parameters when actions require input. Format as nested XML with action name as wrapper.
204
- </keys>
171
+ 2. PLANNING TYPE:
172
+ - direct_action: Single action, no planning needed
173
+ - sequential_planning: Multiple steps in sequence
174
+ - strategic_planning: Complex coordination with stakeholders
175
+
176
+ 3. REQUIRED CAPABILITIES:
177
+ - List specific capabilities needed (analysis, communication, project_management, etc.)
178
+
179
+ 4. STAKEHOLDERS:
180
+ - List types of people/groups involved
181
+
182
+ 5. CONSTRAINTS:
183
+ - List limitations or requirements mentioned
184
+
185
+ 6. DEPENDENCIES:
186
+ - List dependencies between tasks or external factors
187
+
188
+ Respond in this exact format:
189
+ COMPLEXITY: [simple|medium|complex|enterprise]
190
+ PLANNING: [direct_action|sequential_planning|strategic_planning]
191
+ CAPABILITIES: [comma-separated list]
192
+ STAKEHOLDERS: [comma-separated list]
193
+ CONSTRAINTS: [comma-separated list]
194
+ DEPENDENCIES: [comma-separated list]
195
+ CONFIDENCE: [0.0-1.0]"""
205
196
 
206
- <output>
207
- Do NOT include any thinking, reasoning, or <think> sections in your response.
208
- Go directly to the XML response format without any preamble or explanation.
197
+ MESSAGE_HANDLER_TEMPLATE = """task: Generate dialog and actions for {{agentName}}.
209
198
 
210
- Respond using XML format like this:
199
+ context:
200
+ {{providers}}
201
+
202
+ rules[10]:
203
+ - think briefly, then respond
204
+ - always include a <thought> field, even for direct replies
205
+ - actions execute in listed order
206
+ - if replying, REPLY goes first
207
+ - use IGNORE or STOP only by themselves
208
+ - include providers only when needed
209
+ - use provider_hints from context when present instead of restating the same rules
210
+ - if an action needs inputs, include them inside that action's <params> block
211
+ - if a required param is unknown, ask for clarification in text
212
+ - 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
213
+
214
+ control_actions:
215
+ - STOP means the task is done and the agent should end the run without executing more actions
216
+ - STOP is a terminal control action even if it is not listed in available actions
217
+
218
+ fields[5]{name,meaning}:
219
+ - thought | short plan
220
+ - actions | ordered <action> entries inside <actions>
221
+ - providers | array of provider names, or empty
222
+ - text | next message for {{agentName}}
223
+ - simple | true or false
224
+
225
+ formatting:
226
+ - wrap multi-line code in fenced code blocks
227
+ - use inline backticks for short code identifiers
228
+
229
+ output:
230
+ XML only. Return exactly one <response>...</response> document. No prose before or after it. No <think>.
231
+
232
+ Example:
211
233
  <response>
212
- <thought>Your thought here</thought>
213
- <actions>ACTION1,ACTION2</actions>
214
- <providers>PROVIDER1,PROVIDER2</providers>
215
- <text>Your response text here</text>
216
- <params>
217
- <ACTION1>
218
- <paramName1>value1</paramName1>
219
- <paramName2>value2</paramName2>
220
- </ACTION1>
221
- <ACTION2>
222
- <paramName1>value1</paramName1>
223
- </ACTION2>
224
- </params>
225
- </response>
226
-
227
- The <params> block is optional - only include when actions require input parameters.
228
- If an action has no parameters or you're only using REPLY/IGNORE, omit <params> entirely.
229
-
230
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.
231
- </output>"""
232
-
233
- MULTI_STEP_DECISION_TEMPLATE = """<task>
234
- Determine the next step the assistant should take in this conversation to help the user reach their goal.
235
- </task>
234
+ <thought>Reply briefly. No extra providers needed.</thought>
235
+ <actions>
236
+ <action>
237
+ <name>REPLY</name>
238
+ </action>
239
+ </actions>
240
+ <providers></providers>
241
+ <text>Your message here</text>
242
+ <simple>true</simple>
243
+ </response>"""
244
+
245
+ MULTI_STEP_DECISION_TEMPLATE = """Determine the next step the assistant should take in this conversation to help the user reach their goal.
236
246
 
237
247
  {{recentMessages}}
238
248
 
@@ -258,27 +268,21 @@ These are the actions or data provider calls that have already been used in this
258
268
 
259
269
  {{actionResults}}
260
270
 
261
- <keys>
271
+ keys:
262
272
  "thought" Clearly explain your reasoning for the selected providers and/or action, and how this step contributes to resolving the user's request.
263
273
  "action" Name of the action to execute after providers return (can be empty if no action is needed).
264
274
  "providers" List of provider names to call in this step (can be empty if none are needed).
265
275
  "isFinish" Set to true only if the task is fully complete.
266
- </keys>
267
276
 
268
277
  ⚠️ IMPORTANT: Do **not** mark the task as `isFinish: true` immediately after calling an action. Wait for the action to complete before deciding the task is finished.
269
278
 
270
- <output>
271
- <response>
272
- <thought>Your thought here</thought>
273
- <action>ACTION</action>
274
- <providers>PROVIDER1,PROVIDER2</providers>
275
- <isFinish>true | false</isFinish>
276
- </response>
277
- </output>"""
279
+ output:
280
+ thought: Your thought here
281
+ action: ACTION
282
+ providers[2]: PROVIDER1,PROVIDER2
283
+ isFinish: false"""
278
284
 
279
- MULTI_STEP_SUMMARY_TEMPLATE = """<task>
280
- Summarize what the assistant has done so far and provide a final response to the user based on the completed steps.
281
- </task>
285
+ MULTI_STEP_SUMMARY_TEMPLATE = """Summarize what the assistant has done so far and provide a final response to the user based on the completed steps.
282
286
 
283
287
  # Context Information
284
288
  {{bio}}
@@ -306,13 +310,10 @@ Here are the actions taken by the assistant to fulfill the request:
306
310
 
307
311
  - Review the execution trace and last reasoning step carefully
308
312
 
309
- - Your final output MUST be in this XML format:
310
- <output>
311
- <response>
312
- <thought>Your thought here</thought>
313
- <text>Your final message to the user</text>
314
- </response>
315
- </output>"""
313
+ - Your final output MUST be TOON in this format:
314
+ output:
315
+ thought: Your thought here
316
+ text: Your final message to the user"""
316
317
 
317
318
  OPTION_EXTRACTION_TEMPLATE = """# Task: Extract selected task and option from user message
318
319
 
@@ -328,40 +329,66 @@ OPTION_EXTRACTION_TEMPLATE = """# Task: Extract selected task and option from us
328
329
  3. Return the task ID (shortened UUID) and selected option name exactly as listed above
329
330
  4. If no clear selection is made, return null for both fields
330
331
 
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
332
 
334
- Return in XML format:
335
- <response>
336
- <taskId>string_or_null</taskId>
337
- <selectedOption>OPTION_NAME_or_null</selectedOption>
338
- </response>
333
+ Return in TOON format:
334
+ taskId: string_or_null
335
+ selectedOption: OPTION_NAME_or_null
336
+
337
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
339
338
 
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>."""
339
+ POST_ACTION_DECISION_TEMPLATE = """Continue helping the user after reviewing the latest action results.
340
+
341
+ context:
342
+ {{providers}}
343
+
344
+ recent conversation:
345
+ {{recentMessages}}
346
+
347
+ recent action results:
348
+ {{actionResults}}
349
+
350
+ latest reflection task status:
351
+ {{taskCompletionStatus}}
352
+
353
+ rules[10]:
354
+ - think briefly, then continue the task from the latest action results
355
+ - actions execute in listed order
356
+ - if replying, REPLY goes first
357
+ - use IGNORE or STOP only by themselves
358
+ - include providers only when needed
359
+ - use provider_hints from context when present instead of restating the same rules
360
+ - if an action needs inputs, include them under params keyed by action name
361
+ - if a required param is unknown, ask for clarification in text
362
+ - if reflection says the task is incomplete, keep working or explain the concrete follow-up you still need
363
+ - if the task is complete, either reply to the user or use STOP to end the run
364
+ - STOP is a terminal control action even if it is not listed in available actions
365
+
366
+ output:
367
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
368
+
369
+ thought: Your thought here
370
+ actions[1]: ACTION
371
+ providers[0]:
372
+ text: Your message here
373
+ simple: true"""
341
374
 
342
375
  POST_CREATION_TEMPLATE = """# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.
343
376
 
344
377
  Example task outputs:
345
378
  1. A post about the importance of AI in our lives
346
- <response>
347
- <thought>I am thinking about writing a post about the importance of AI in our lives</thought>
348
- <post>AI is changing the world and it is important to understand how it works</post>
349
- <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>
350
- </response>
379
+ thought: I am thinking about writing a post about the importance of AI in our lives
380
+ post: AI is changing the world and it is important to understand how it works
381
+ imagePrompt: A futuristic cityscape with flying cars and people using AI to do things
351
382
 
352
383
  2. A post about dogs
353
- <response>
354
- <thought>I am thinking about writing a post about dogs</thought>
355
- <post>Dogs are man's best friend and they are loyal and loving</post>
356
- <imagePrompt>A dog playing with a ball in a park</imagePrompt>
357
- </response>
384
+ thought: I am thinking about writing a post about dogs
385
+ post: Dogs are man's best friend and they are loyal and loving
386
+ imagePrompt: A dog playing with a ball in a park
358
387
 
359
388
  3. A post about finding a new job
360
- <response>
361
- <thought>Getting a job is hard, I bet there's a good post in that</thought>
362
- <post>Just keep going!</post>
363
- <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>
364
- </response>
389
+ thought: Getting a job is hard, I bet there's a good post in that
390
+ post: Just keep going!
391
+ imagePrompt: A person looking at a computer screen with a job search website
365
392
 
366
393
  {{providers}}
367
394
 
@@ -369,21 +396,17 @@ Write a post that is {{adjective}} about {{topic}} (without mentioning {{topic}}
369
396
  Your response should be 1, 2, or 3 sentences (choose the length at random).
370
397
  Your response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.
371
398
 
372
- Your output should be formatted in XML like this:
373
- <response>
374
- <thought>Your thought here</thought>
375
- <post>Your post text here</post>
376
- <imagePrompt>Optional image prompt here</imagePrompt>
377
- </response>
399
+ Your output should be formatted as TOON like this:
400
+ thought: Your thought here
401
+ post: Your post text here
402
+ imagePrompt: Optional image prompt here
378
403
 
379
404
  The "post" field should be the post you want to send. Do not including any thinking or internal reflection in the "post" field.
380
405
  The "imagePrompt" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.
381
406
  The "thought" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.
382
407
 
383
- Do NOT include any thinking, reasoning, or <think> sections in your response.
384
- Go directly to the XML response format without any preamble or explanation.
385
408
 
386
- 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>."""
409
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
387
410
 
388
411
  REFLECTION_EVALUATOR_TEMPLATE = """# Task: Generate Agent Reflection, Extract Facts and Relationships
389
412
 
@@ -408,40 +431,49 @@ Message Sender: {{senderName}} (ID: {{senderId}})
408
431
  # Known Facts:
409
432
  {{knownFacts}}
410
433
 
434
+ # Latest Action Results:
435
+ {{actionResults}}
436
+
411
437
  # Instructions:
412
438
  1. Generate a self-reflective thought on the conversation about your performance and interaction quality.
413
- 2. Extract new facts from the conversation.
439
+ 2. Extract only durable new facts from the conversation.
440
+ - 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.
441
+ - 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.
442
+ - If a fact would feel stale, irrelevant, or surprising to store a week from now, skip it.
443
+ - When in doubt, omit the fact.
414
444
  3. Identify and describe relationships between entities.
415
445
  - The sourceEntityId is the UUID of the entity initiating the interaction.
416
446
  - The targetEntityId is the UUID of the entity being interacted with.
417
447
  - Relationships are one-direction, so a friendship would be two entity relationships where each entity is both the source and the target of the other.
418
-
419
- Do NOT include any thinking, reasoning, or <think> sections in your response.
420
- Go directly to the XML response format without any preamble or explanation.
421
-
422
- Generate a response in the following format:
423
- <response>
424
- <thought>a self-reflective thought on the conversation</thought>
425
- <facts>
426
- <fact>
427
- <claim>factual statement</claim>
428
- <type>fact|opinion|status</type>
429
- <in_bio>false</in_bio>
430
- <already_known>false</already_known>
431
- </fact>
432
- <!-- Add more facts as needed -->
433
- </facts>
434
- <relationships>
435
- <relationship>
436
- <sourceEntityId>entity_initiating_interaction</sourceEntityId>
437
- <targetEntityId>entity_being_interacted_with</targetEntityId>
438
- <tags>group_interaction,voice_interaction,dm_interaction,additional_tag1,additional_tag2</tags>
439
- </relationship>
440
- <!-- Add more relationships as needed -->
441
- </relationships>
442
- </response>
443
-
444
- 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>."""
448
+ 4. It is normal to return no facts when nothing durable was learned.
449
+ 5. Always decide whether the user's task or request is actually complete right now.
450
+ - Set `task_completed: true` only if the user no longer needs additional action or follow-up from you in this turn.
451
+ - If you asked a clarifying question, an action failed, work is still pending, or you only partially completed the request, set `task_completed: false`.
452
+ 6. Always include a short `task_completion_reason` grounded in the conversation and action results.
453
+
454
+ Output:
455
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
456
+ Do not output JSON, XML, Markdown fences, or commentary.
457
+ Use indexed TOON fields exactly like this:
458
+ thought: "a self-reflective thought on the conversation"
459
+ task_completed: false
460
+ task_completion_reason: "The request is still incomplete because the needed action has not happened yet."
461
+ facts[0]:
462
+ claim: durable factual statement
463
+ type: fact
464
+ in_bio: false
465
+ already_known: false
466
+ relationships[0]:
467
+ sourceEntityId: entity_initiating_interaction
468
+ targetEntityId: entity_being_interacted_with
469
+ tags[0]: dm_interaction
470
+
471
+ For additional entries, increment the index: facts[1], relationships[1], tags[1], etc.
472
+ Always include `task_completed` and `task_completion_reason`.
473
+ If there are no durable new facts, omit all facts[...] entries.
474
+ If there are no relationships, omit all relationships[...] entries.
475
+
476
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
445
477
 
446
478
  REFLECTION_TEMPLATE = """# Task: Reflect on recent agent behavior and interactions.
447
479
 
@@ -457,16 +489,35 @@ Analyze the agent's recent behavior and interactions. Consider:
457
489
  3. Were any mistakes made?
458
490
  4. What could be improved?
459
491
 
460
- Respond using XML format like this:
461
- <response>
462
- <thought>Your detailed analysis</thought>
463
- <quality_score>Score 0-100 for overall quality</quality_score>
464
- <strengths>What went well</strengths>
465
- <improvements>What could be improved</improvements>
466
- <learnings>Key takeaways for future interactions</learnings>
467
- </response>
492
+ Respond using TOON like this:
493
+ thought: Your detailed analysis
494
+ quality_score: Score 0-100 for overall quality
495
+ strengths: What went well
496
+ improvements: What could be improved
497
+ learnings: Key takeaways for future interactions
498
+
499
+ IMPORTANT: Your response must ONLY contain the TOON document above."""
500
+
501
+ REMOVE_CONTACT_TEMPLATE = """task: Extract the contact removal request.
502
+
503
+ context:
504
+ {{providers}}
505
+
506
+ current_message:
507
+ {{message}}
508
+
509
+ instructions[4]:
510
+ - identify the contact name to remove
511
+ - set confirmed to yes only when the user explicitly confirms removal
512
+ - set confirmed to no when confirmation is absent or ambiguous
513
+ - return only the requested contact
514
+
515
+ output:
516
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
468
517
 
469
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above."""
518
+ Example:
519
+ contactName: Jane Doe
520
+ confirmed: yes"""
470
521
 
471
522
  REPLY_TEMPLATE = """# Task: Generate dialog for the character {{agentName}}.
472
523
 
@@ -483,49 +534,279 @@ IMPORTANT CODE BLOCK FORMATTING RULES:
483
534
  - This ensures the user sees clearly formatted and copyable code when relevant.
484
535
 
485
536
  Do NOT include any thinking, reasoning, or <think> sections in your response.
486
- Go directly to the XML response format without any preamble or explanation.
537
+ Go directly to the TOON response format without any preamble or explanation.
487
538
 
488
- Respond using XML format like this:
489
- <response>
490
- <thought>Your thought here</thought>
491
- <text>Your message here</text>
492
- </response>
539
+ Respond using TOON like this:
540
+ thought: Your thought here
541
+ text: Your message here
493
542
 
494
- 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>."""
543
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any text, thinking, or reasoning before or after it."""
495
544
 
496
- SHOULD_RESPOND_TEMPLATE = """<task>Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.</task>
545
+ SCHEDULE_FOLLOW_UP_TEMPLATE = """task: Extract follow-up scheduling information from the request.
497
546
 
498
- <providers>
547
+ context:
499
548
  {{providers}}
500
- </providers>
501
549
 
502
- <instructions>Decide if {{agentName}} should respond to or interact with the conversation.
550
+ current_message:
551
+ {{message}}
503
552
 
504
- IMPORTANT RULES FOR RESPONDING:
505
- - If YOUR name ({{agentName}}) is directly mentioned → RESPOND
506
- - If someone uses a DIFFERENT name (not {{agentName}}) → IGNORE (they're talking to someone else)
507
- - If you're actively participating in a conversation and the message continues that thread → RESPOND
508
- - If someone tells you to stop or be quiet → STOP
509
- - Otherwise → IGNORE
553
+ current_datetime:
554
+ {{currentDateTime}}
510
555
 
511
- The key distinction is:
512
- - "Talking TO {{agentName}}" (your name mentioned, replies to you, continuing your conversation) → RESPOND
513
- - "Talking ABOUT {{agentName}}" or to someone else → IGNORE
514
- </instructions>
556
+ instructions[5]:
557
+ - identify who to follow up with
558
+ - include entityId only when it is explicitly known
559
+ - convert requested timing into an ISO datetime in scheduledAt
560
+ - normalize priority to high, medium, or low
561
+ - include message only when the user asked for a specific note or reminder text
515
562
 
516
- <output>
517
- Do NOT include any thinking, reasoning, or <think> sections in your response.
518
- Go directly to the XML response format without any preamble or explanation.
563
+ output:
564
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
519
565
 
520
- Respond using XML format like this:
521
- <response>
522
- <name>{{agentName}}</name>
523
- <reasoning>Your reasoning here</reasoning>
524
- <action>RESPOND | IGNORE | STOP</action>
525
- </response>
566
+ Example:
567
+ contactName: Jane Doe
568
+ entityId:
569
+ scheduledAt: 2026-04-06T14:00:00.000Z
570
+ reason: Check in on the proposal
571
+ priority: medium
572
+ message: Send the latest deck before the call"""
573
+
574
+ SEARCH_CONTACTS_TEMPLATE = """task: Extract contact search criteria from the request.
575
+
576
+ context:
577
+ {{providers}}
578
+
579
+ current_message:
580
+ {{message}}
526
581
 
527
- 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>.
528
- </output>"""
582
+ instructions[5]:
583
+ - return categories as a comma-separated list when the user filters by category
584
+ - return tags as a comma-separated list when the user filters by tags
585
+ - return searchTerm for any name or free-text lookup
586
+ - set intent to count when the user only wants a count, otherwise list
587
+ - omit fields that are not clearly requested
588
+
589
+ output:
590
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
591
+
592
+ Example:
593
+ categories: vip,colleague
594
+ searchTerm: Jane
595
+ tags: ai,design
596
+ intent: list"""
597
+
598
+ SHOULD_FOLLOW_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should follow this room.
599
+
600
+ context:
601
+ {{providers}}
602
+
603
+ current_message:
604
+ {{message}}
605
+
606
+ instructions[3]:
607
+ - return true only when the user is clearly asking {{agentName}} to follow, join, listen to, or stay engaged in this room
608
+ - return false when the request is ambiguous or unrelated
609
+ - prefer false when uncertain
610
+
611
+ output:
612
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
613
+
614
+ Example:
615
+ decision: true"""
616
+
617
+ SHOULD_MUTE_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should mute this room.
618
+
619
+ context:
620
+ {{providers}}
621
+
622
+ current_message:
623
+ {{message}}
624
+
625
+ instructions[3]:
626
+ - return true only when the user is clearly asking {{agentName}} to mute, silence, or ignore this room
627
+ - return false when the request is ambiguous or unrelated
628
+ - prefer false when uncertain
629
+
630
+ output:
631
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
632
+
633
+ Example:
634
+ decision: true"""
635
+
636
+ SHOULD_RESPOND_TEMPLATE = """task: Decide whether {{agentName}} should respond, ignore, or stop.
637
+
638
+ context:
639
+ {{providers}}
640
+
641
+ rules[6]:
642
+ - direct mention of {{agentName}} -> RESPOND
643
+ - different assistant name or talking to someone else -> IGNORE unless {{agentName}} is also directly addressed
644
+ - prior participation by {{agentName}} in the thread is not enough by itself; the newest message must still clearly expect {{agentName}} -> otherwise IGNORE
645
+ - request to stop or be quiet directed at {{agentName}} -> STOP
646
+ - if multiple people are mentioned and {{agentName}} is one of the addressees -> RESPOND
647
+ - if unsure whether the speaker is talking to {{agentName}}, prefer IGNORE over hallucinating relevance
648
+
649
+ available_contexts:
650
+ {{availableContexts}}
651
+
652
+ context_routing:
653
+ - primaryContext: choose one context from available_contexts, or "general" if none apply
654
+ - secondaryContexts: optional comma-separated list of additional relevant contexts
655
+ - evidenceTurnIds: optional comma-separated list of message IDs supporting the decision
656
+
657
+ decision_note:
658
+ - respond only when the latest message is talking TO {{agentName}}
659
+ - talking TO {{agentName}} means name mention, reply chain, or a clear follow-up that still expects {{agentName}} to answer
660
+ - mentions of other people do not cancel a direct address to {{agentName}}
661
+ - casual conversation between other users is not enough
662
+ - if another assistant already answered and nobody re-addressed {{agentName}}, IGNORE
663
+ - if {{agentName}} already replied recently and nobody re-addressed {{agentName}}, IGNORE
664
+ - talking ABOUT {{agentName}} or continuing a room conversation around them is not enough
665
+
666
+ output:
667
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
668
+
669
+ Example:
670
+ name: {{agentName}}
671
+ reasoning: Direct mention and clear follow-up.
672
+ action: RESPOND
673
+ primaryContext: general
674
+ secondaryContexts:
675
+ evidenceTurnIds:"""
676
+
677
+ SHOULD_RESPOND_WITH_CONTEXT_TEMPLATE = """task: Decide whether {{agentName}} should respond and which domain context applies.
678
+
679
+ context:
680
+ {{providers}}
681
+
682
+ available_contexts:
683
+ {{availableContexts}}
684
+
685
+ rules[6]:
686
+ - direct mention of {{agentName}} -> RESPOND
687
+ - different assistant name or talking to someone else -> IGNORE unless {{agentName}} is also directly addressed
688
+ - prior participation by {{agentName}} in the thread is not enough by itself; the newest message must still clearly expect {{agentName}} -> otherwise IGNORE
689
+ - request to stop or be quiet directed at {{agentName}} -> STOP
690
+ - if multiple people are mentioned and {{agentName}} is one of the addressees -> RESPOND
691
+ - if unsure whether the speaker is talking to {{agentName}}, prefer IGNORE over hallucinating relevance
692
+
693
+ context_routing:
694
+ - primaryContext: the single best-matching domain from available_contexts
695
+ - secondaryContexts: zero or more additional domains that are relevant
696
+ - action intent does not only come from the last message; consider the full recent conversation
697
+ - if no specific domain applies, use "general"
698
+
699
+ decision_note:
700
+ - respond only when the latest message is talking TO {{agentName}}
701
+ - talking TO {{agentName}} means name mention, reply chain, or a clear follow-up that still expects {{agentName}} to answer
702
+ - mentions of other people do not cancel a direct address to {{agentName}}
703
+ - casual conversation between other users is not enough
704
+ - if another assistant already answered and nobody re-addressed {{agentName}}, IGNORE
705
+ - if {{agentName}} already replied recently and nobody re-addressed {{agentName}}, IGNORE
706
+ - talking ABOUT {{agentName}} or continuing a room conversation around them is not enough
707
+ - context routing always applies, even for IGNORE/STOP decisions
708
+
709
+ output:
710
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
711
+
712
+ Example:
713
+ name: {{agentName}}
714
+ reasoning: Direct mention asking about token balance.
715
+ action: RESPOND
716
+ primaryContext: wallet
717
+ secondaryContexts: []"""
718
+
719
+ SHOULD_UNFOLLOW_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should unfollow this room.
720
+
721
+ context:
722
+ {{providers}}
723
+
724
+ current_message:
725
+ {{message}}
726
+
727
+ instructions[3]:
728
+ - return true only when the user is clearly asking {{agentName}} to stop following or leave this room
729
+ - return false when the request is ambiguous or unrelated
730
+ - prefer false when uncertain
731
+
732
+ output:
733
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
734
+
735
+ Example:
736
+ decision: true"""
737
+
738
+ SHOULD_UNMUTE_ROOM_TEMPLATE = """task: Decide whether {{agentName}} should unmute this room.
739
+
740
+ context:
741
+ {{providers}}
742
+
743
+ current_message:
744
+ {{message}}
745
+
746
+ instructions[3]:
747
+ - return true only when the user is clearly asking {{agentName}} to unmute or resume listening to this room
748
+ - return false when the request is ambiguous or unrelated
749
+ - prefer false when uncertain
750
+
751
+ output:
752
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
753
+
754
+ Example:
755
+ decision: true"""
756
+
757
+ THINK_TEMPLATE = """# Task: Think deeply and reason carefully for {{agentName}}.
758
+
759
+ {{providers}}
760
+
761
+ # Context
762
+ The initial planning phase identified this question as requiring deeper analysis.
763
+ The following is the conversation so far and all available context.
764
+
765
+ # Instructions
766
+ 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.
767
+
768
+ Approach this systematically:
769
+ 1. Identify the core question or problem being asked
770
+ 2. Consider multiple angles, approaches, or interpretations
771
+ 3. Evaluate trade-offs, risks, and constraints
772
+ 4. Draw on relevant knowledge and context from the conversation
773
+ 5. Arrive at a well-reasoned conclusion or recommendation
774
+
775
+ Be thorough but concise. Prioritize depth of reasoning over length. If there are genuine unknowns, acknowledge them rather than guessing.
776
+
777
+ Respond using TOON:
778
+ thought: Your detailed internal reasoning — the full chain of thought, alternatives considered, and why you reached your conclusion
779
+ text: Your response to the user — clear, structured, and well-reasoned. Use headings, lists, or code blocks as appropriate for the content.
780
+
781
+ IMPORTANT: Your response must ONLY contain the TOON document above. Do not include any preamble or explanation outside of it."""
782
+
783
+ UPDATE_CONTACT_TEMPLATE = """task: Extract contact updates from the request.
784
+
785
+ context:
786
+ {{providers}}
787
+
788
+ current_message:
789
+ {{message}}
790
+
791
+ instructions[6]:
792
+ - identify the contact name to update
793
+ - set operation to replace unless the user clearly says to add_to or remove_from
794
+ - return categories and tags as comma-separated lists
795
+ - return preferences and customFields as comma-separated key:value pairs
796
+ - include notes only when explicitly requested
797
+ - omit fields that are not being changed
798
+
799
+ output:
800
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
801
+
802
+ Example:
803
+ contactName: Jane Doe
804
+ operation: add_to
805
+ categories: vip
806
+ tags: ai,friend
807
+ preferences: timezone:America/New_York,language:English
808
+ customFields: company:Acme,title:Designer
809
+ notes: Prefers async communication"""
529
810
 
530
811
  UPDATE_ENTITY_TEMPLATE = """# Task: Update entity information.
531
812
 
@@ -538,19 +819,43 @@ UPDATE_ENTITY_TEMPLATE = """# Task: Update entity information.
538
819
  Based on the request, determine what information about the entity should be updated.
539
820
  Only update fields that the user has explicitly requested to change.
540
821
 
541
- Respond using XML format like this:
542
- <response>
543
- <thought>Your reasoning for the entity update</thought>
544
- <entity_id>The entity ID to update</entity_id>
545
- <updates>
546
- <field>
547
- <name>field_name</name>
548
- <value>new_value</value>
549
- </field>
550
- </updates>
551
- </response>
552
-
553
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above."""
822
+ Respond using TOON like this:
823
+ thought: Your reasoning for the entity update
824
+ entity_id: The entity ID to update
825
+ updates[1]{name,value}:
826
+ field_name,new_value
827
+
828
+ IMPORTANT: Your response must ONLY contain the TOON document above."""
829
+
830
+ UPDATE_ROLE_TEMPLATE = """task: Extract the requested role change.
831
+
832
+ context:
833
+ {{providers}}
834
+
835
+ current_roles:
836
+ {{roles}}
837
+
838
+ recent_messages:
839
+ {{recentMessages}}
840
+
841
+ current_message:
842
+ {{message}}
843
+
844
+ instructions[6]:
845
+ - identify the single entity whose role should be updated
846
+ - return entity_id only when the UUID is explicit in context
847
+ - normalize new_role to one of OWNER, ADMIN, MEMBER, GUEST, or NONE
848
+ - if the user is removing elevated access without naming a new role, use NONE
849
+ - do not invent entity ids or roles
850
+ - include a short thought describing the change
851
+
852
+ output:
853
+ TOON only. Return exactly one TOON document. No prose before or after it. No <think>.
854
+
855
+ Example:
856
+ thought: Sarah should become an admin.
857
+ entity_id: 00000000-0000-0000-0000-000000000000
858
+ new_role: ADMIN"""
554
859
 
555
860
  UPDATE_SETTINGS_TEMPLATE = """# Task: Update settings based on the request.
556
861
 
@@ -563,22 +868,17 @@ UPDATE_SETTINGS_TEMPLATE = """# Task: Update settings based on the request.
563
868
  Based on the request, determine which settings to update.
564
869
  Only update settings that the user has explicitly requested.
565
870
 
566
- Respond using XML format like this:
567
- <response>
568
- <thought>Your reasoning for the settings changes</thought>
569
- <updates>
570
- <update>
571
- <key>setting_key</key>
572
- <value>new_value</value>
573
- </update>
574
- </updates>
575
- </response>
871
+ Respond using TOON like this:
872
+ thought: Your reasoning for the settings changes
873
+ updates[1]{key,value}:
874
+ setting_key,new_value
576
875
 
577
- IMPORTANT: Your response must ONLY contain the <response></response> XML block above."""
876
+ IMPORTANT: Your response must ONLY contain the TOON document above."""
578
877
 
579
878
  BOOLEAN_FOOTER = "Respond with only a YES or a NO."
580
879
 
581
880
  __all__ = [
881
+ "ADD_CONTACT_TEMPLATE",
582
882
  "AUTONOMY_CONTINUOUS_CONTINUE_TEMPLATE",
583
883
  "AUTONOMY_CONTINUOUS_FIRST_TEMPLATE",
584
884
  "AUTONOMY_TASK_CONTINUE_TEMPLATE",
@@ -586,16 +886,29 @@ __all__ = [
586
886
  "CHOOSE_OPTION_TEMPLATE",
587
887
  "IMAGE_DESCRIPTION_TEMPLATE",
588
888
  "IMAGE_GENERATION_TEMPLATE",
889
+ "MESSAGE_CLASSIFIER_TEMPLATE",
589
890
  "MESSAGE_HANDLER_TEMPLATE",
590
891
  "MULTI_STEP_DECISION_TEMPLATE",
591
892
  "MULTI_STEP_SUMMARY_TEMPLATE",
592
893
  "OPTION_EXTRACTION_TEMPLATE",
894
+ "POST_ACTION_DECISION_TEMPLATE",
593
895
  "POST_CREATION_TEMPLATE",
594
896
  "REFLECTION_EVALUATOR_TEMPLATE",
595
897
  "REFLECTION_TEMPLATE",
898
+ "REMOVE_CONTACT_TEMPLATE",
596
899
  "REPLY_TEMPLATE",
900
+ "SCHEDULE_FOLLOW_UP_TEMPLATE",
901
+ "SEARCH_CONTACTS_TEMPLATE",
902
+ "SHOULD_FOLLOW_ROOM_TEMPLATE",
903
+ "SHOULD_MUTE_ROOM_TEMPLATE",
597
904
  "SHOULD_RESPOND_TEMPLATE",
905
+ "SHOULD_RESPOND_WITH_CONTEXT_TEMPLATE",
906
+ "SHOULD_UNFOLLOW_ROOM_TEMPLATE",
907
+ "SHOULD_UNMUTE_ROOM_TEMPLATE",
908
+ "THINK_TEMPLATE",
909
+ "UPDATE_CONTACT_TEMPLATE",
598
910
  "UPDATE_ENTITY_TEMPLATE",
911
+ "UPDATE_ROLE_TEMPLATE",
599
912
  "UPDATE_SETTINGS_TEMPLATE",
600
913
  "BOOLEAN_FOOTER",
601
914
  ]