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
dynamic tool call works! with context injection (chat History not shared with tool call service, only 'tool call goal' and tool choice from build-test subagent)
Copy file name to clipboardExpand all lines: packages/core/src/agents/build-test-agent.ts
+16-9Lines changed: 16 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -178,13 +178,16 @@ You have access to these tools:
178
178
\${directive}
179
179
`,
180
180
directive: `## Output Format
181
+
If you decide to choose a tool to further the task, your response must *ONLY* contain the tool choice in JSON format.
181
182
182
-
If you decide to choose a tool to further the task, your response must *ONLY* contain a one-line explanation of your rationale, followed by the tool choice in JSON format.
183
+
The \`goal\` you provide is critical, as it will be passed to a separate, specialized agent that executes the command. This agent has **no access to our conversation history**. Therefore, your \`goal\` **must be a fully self-contained and actionable instruction**. It needs to include not just *what* to do, but also *why*, so the other agent understands the context.
183
184
184
-
**Example:**
185
-
I have chosen \`tool_name\` because [Your concise rationale and what you are trying to do and why it will help].
185
+
**JSON Structure:**
186
186
\`\`\`json
187
-
{ "name": "tool_name" }
187
+
{
188
+
"name": "run_shell_command",
189
+
"goal": "<Your fully self-contained goal>"
190
+
}
188
191
\`\`\`
189
192
190
193
If you decide the user's objective is met, your response must *ONLY* contain a five bullet point summary (e.g., test names, file names, pass/fail status), followed by the \`complete_task\` tool call in JSON format.
@@ -202,20 +205,24 @@ I am satisfied with the results. Here are the execution highlights:
202
205
203
206
`,
204
207
reminder: `Remember! You are a **Build And Test Agent** whose purpose is to build and/or test code according to the user's objective.
205
-
208
+
206
209
## Available Tools
207
210
You have access to these tools:
208
211
\${tool_code}
209
212
210
213
211
214
## Output Format
215
+
If you decide to choose a tool to further the task, your response must *ONLY* contain the tool choice in JSON format.
212
216
213
-
If you decide to choose a tool to further the task, your response must *ONLY* contain a one-line explanation of your rationale, followed by the tool choice in JSON format.
217
+
The \`goal\` you provide is critical, as it will be passed to a separate, specialized agent that executes the command. This agent has **no access to our conversation history**. Therefore, your \`goal\` **must be a fully self-contained and actionable instruction**. It needs to include not just *what* to do, but also *why*, so the other agent understands the context.
214
218
215
-
**Example:**
216
-
I have chosen \`tool_name\` because [Your concise rationale and what you are trying to do and why it will help].
219
+
220
+
**JSON Structure:**
217
221
\`\`\`json
218
-
{ "name": "tool_name" }
222
+
{
223
+
"name": "run_shell_command",
224
+
"goal": "<Your fully self-contained goal>"
225
+
}
219
226
\`\`\`
220
227
221
228
If you decide the user's objective is met, your response must *ONLY* contain a five bullet point summary (e.g., test names, file names, pass/fail status), followed by the \`complete_task\` tool call in JSON format.
letfileContents='Tool Call Service Chat History\n\n';
109
99
110
100
constsystemPrompt=`You are a tool call generator. Your task is to generate a valid tool call for the tool named "${toolName}".
111
-
You will be provided with the schema of the tool and the chat history.
112
-
Generate a tool call that best helps with the user's request.
101
+
You will be provided with the schema of the tool and a goal.
102
+
Generate a tool call that best helps with achieving the goal.
103
+
104
+
You must return a single JSON object with the following structure:
105
+
{
106
+
"name": "${toolName}",
107
+
"parameters": { ... }
108
+
}
113
109
The tool schema is:
114
110
${formattedSchema}
115
111
116
112
Respond with only the JSON for the tool call. Do not include any other text or markdown.
117
-
118
-
The
119
113
`;
120
-
121
-
constreminder=`Remember!
122
-
You must look at the preceding chat history to understand the user's objective and current step in the process.
123
-
Only respond with the JSON for the tool call. Do not include any other text or markdown.`;
124
-
125
-
// TODO: add a user message which actually has the formatted schema and a reiteration of the user's objective and asks what command must be called. that will replace text: ''. maybe it's fine to have the schema and tool name in the system prompt.
114
+
fileContents+=`--- ROLE: system ---\n${systemPrompt}\n---\n\n`;
115
+
awaitthis._writeChatHistoryToFile(fileContents);
126
116
127
117
consttempChat=newOllamaChat(
128
118
modelConfigasOllamaModelConfig,
129
119
systemPrompt,
130
-
// [],
131
-
chatHistory,
120
+
[],
132
121
{
133
122
query: '',
134
123
systemPrompt,
135
124
},
136
125
);
137
126
127
+
constuserMessage=`The goal is: ${goal}`;
128
+
fileContents+=`--- ROLE: user ---\n${userMessage}\n---\n\n`;
0 commit comments