You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLPlanExecuteAndReflectAgentRunner.java
Copy file name to clipboardExpand all lines: ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/PromptTemplate.java
+69-45Lines changed: 69 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -81,51 +81,75 @@ public class PromptTemplate {
81
81
6. The final response should be fully self-contained and detailed, allowing a user to understand the full investigation without needing to reference prior messages and steps.
+ "Only respond in JSON format. Always follow the given response instructions. Do not return any content that does not follow the response instructions. Do not add anything before or after the expected JSON. \n"
86
-
+ "Always respond with a valid JSON object that strictly follows the below schema:\n"
87
-
+ "{\n"
88
-
+ "\t\"steps\": array[string], \n"
89
-
+ "\t\"result\": string \n"
90
-
+ "}\n"
91
-
+ "Use \"steps\" to return an array of strings where each string is a step to complete the objective, leave it empty if you know the final result. Please wrap each step in quotes and escape any special characters within the string. \n"
92
-
+ "Use \"result\" return the final response when you have enough information, leave it empty if you want to execute more steps. Please escape any special characters within the result. \n"
93
-
+ "Here are examples of valid responses following the required JSON schema:\n\n"
94
-
+ "Example 1 - When you need to execute steps:\n"
95
-
+ "{\n"
96
-
+ "\t\"steps\": [\"This is an example step\", \"this is another example step\"],\n"
97
-
+ "\t\"result\": \"\"\n"
98
-
+ "}\n\n"
99
-
+ "Example 2 - When you have the final result:\n"
100
-
+ "{\n"
101
-
+ "\t\"steps\": [],\n"
102
-
+ "\t\"result\": \"This is an example result\\n with escaped special characters\"\n"
103
-
+ "}\n"
104
-
+ "Important rules for the response:\n"
105
-
+ "1. Do not use commas within individual steps \n"
106
-
+ "2. Do not add any content before or after the JSON \n"
107
-
+ "3. Only respond with a pure JSON object \n\n";
108
-
109
-
publicstaticfinalStringPLANNER_RESPONSIBILITY =
110
-
"""
111
-
You are a thoughtful and analytical planner agent in a plan-execute-reflect framework. Your job is to design a clear, step-by-step plan for a given objective.
112
-
113
-
Instructions:
114
-
- Break the objective into an ordered list of atomic, self-contained Steps that, if executed, will lead to the final result or complete the objective.
115
-
- Each Step must state what to do, where, and which tool/parameters would be used. You do not execute tools, only reference them for planning.
116
-
- Use only the provided tools; do not invent or assume tools. If no suitable tool applies, use reasoning or observations instead.
117
-
- Base your plan only on the data and information explicitly provided; do not rely on unstated knowledge or external facts.
118
-
- If there is insufficient information to create a complete plan, summarize what is known so far and clearly state what additional information is required to proceed.
119
-
- Stop and summarize if the task is complete or further progress is unlikely.
120
-
- Avoid vague instructions; be specific about data sources, indexes, or parameters.
121
-
- Never make assumptions or rely on implicit knowledge.
122
-
- Respond only in JSON format.
123
-
124
-
Step examples:
125
-
Good example: \"Use Tool to sample documents from index: 'my-index'\"
126
-
Bad example: \"Use Tool to sample documents from each index\"
127
-
Bad example: \"Use Tool to sample documents from all indices\"
StringresultExample = "Here are examples of valid responses following the required JSON schema:\n\n"
86
+
+ "Example 1 - When you need to execute steps:\n"
87
+
+ "{\n"
88
+
+ "\t\"steps\": [\"This is an example step\", \"this is another example step\"],\n"
89
+
+ "\t\"result\": \"\"\n"
90
+
+ "}\n\n"
91
+
+ "Example 2 - When you have the final result:\n"
92
+
+ "{\n"
93
+
+ "\t\"steps\": [],\n"
94
+
+ "\t\"result\": \"This is an example result\\n with escaped special characters\"\n"
95
+
+ "}\n";
96
+
97
+
return"# Response Format\n\n"
98
+
+ "## JSON Response Requirements\n"
99
+
+ "Only respond in JSON format. Always follow the given response instructions. Do not return any content that does not follow the response instructions. Do not add anything before or after the expected JSON\n\n"
100
+
+ "Always respond with a valid JSON object that strictly follows the below schema:\n"
101
+
+ "```json\n"
102
+
+ "{\n"
103
+
+ " \"steps\": array[string],\n"
104
+
+ " \"result\": string\n"
105
+
+ "}\n"
106
+
+ "```\n"
107
+
+ "\n"
108
+
+ "- Use \"steps\" to return an array of strings where each string is a step to complete the objective, leave it empty if you know the final result. Please wrap each step in quotes and escape any special characters within the string\n"
109
+
+ "- Use \"result\" to return the final response when you have enough information, leave it empty if you want to execute more steps. "
"# Investigation Planner Agent\n\nYou are a thoughtful and analytical planner agent in a plan-execute-reflect framework. Your job is to design a clear, step-by-step plan for a given objective.\n\n";
127
+
128
+
publicstaticStringgetCorePlanningInstructions() {
129
+
return"""
130
+
# Instructions
131
+
132
+
## Core Planning Rules
133
+
- Break the objective into an ordered list of atomic, self-contained Steps that, if executed, will lead to the final result or complete the objective
134
+
- Each Step must state what to do, where, and which tool/parameters would be used. You do not execute tools, only reference them for planning
135
+
- Use only the provided tools; do not invent or assume tools. If no suitable tool applies, use reasoning or observations instead
136
+
- Base your plan only on the data and information explicitly provided; do not rely on unstated knowledge or external facts
137
+
- If there is insufficient information to create a complete plan, summarize what is known so far and clearly state what additional information is required to proceed
138
+
- Stop and summarize if the task is complete or further progress is unlikely
139
+
- Avoid vague instructions; be specific about data sources, indexes, or parameters
140
+
- Never make assumptions or rely on implicit knowledge
141
+
- Respond only in JSON format
142
+
"""
143
+
+ """
144
+
## Step Examples
145
+
**Good example:** "Use Tool to sample documents from index: 'my-index'"
146
+
147
+
**Bad example:** "Use Tool to sample documents from each index"
148
+
149
+
**Bad example:** "Use Tool to sample documents from all indices"
0 commit comments