Skip to content

Commit bbba3e6

Browse files
committed
ho ho ho tool call service uses full subagen's chat history to make tool call
1 parent 1c1b5a0 commit bbba3e6

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

packages/core/src/agents/executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
6565
import { debugLogger } from '../utils/debugLogger.js';
6666
import type { Part as OllamaPart } from '../core/ollamaChat.js';
6767
// import { extractValidJson } from '../utils/json.js';
68-
import { stripJsonMarkdown } from '../utils/json.js';
68+
6969
import * as fs from 'node:fs/promises';
7070
import type { AnsiOutput } from '../utils/terminalSerializer.js';
7171
import {

packages/core/src/services/toolCallService.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,36 @@ export class ToolCallService {
108108
.join(' ');
109109

110110
const systemPrompt = `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 last user message.
111+
You will be provided with the schema of the tool and the chat history.
112112
Generate a tool call that best helps with the user's request.
113113
The tool schema is:
114114
${formattedSchema}
115115
116116
Respond with only the JSON for the tool call. Do not include any other text or markdown.
117+
118+
The
117119
`;
118120

121+
const reminder = `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.
126+
119127
const tempChat = new OllamaChat(
120128
modelConfig as OllamaModelConfig,
121129
systemPrompt,
122-
[],
130+
// [],
131+
chatHistory,
123132
{
124133
query: '',
125134
systemPrompt,
126135
},
127136
);
128137

129138
const responseStream = await tempChat.sendMessageStream(modelConfig.model, {
130-
message: [{ text: lastMessageText }],
139+
// message: [{ text: lastMessageText }],
140+
message: [{ text: reminder }],
131141
});
132142

133143
let textResponse = '';

understand.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,20 @@ Using the codebase investigator: tell me how the ollama inference works.
248248
environment either due to prompt forgetting)
249249
1. Gemma often forgets which files it's already looked at.
250250

251-
1. Look at chat_history.txt. despite having a summary it still sees status 0 and
252-
decidesit doesn't have the full information.
251+
<!-- -->
253252

254-
1. the dircetive swapping between tool choice and tool call is a little messy.
255-
just verify that later in executor.ts
253+
1. chat_history maybe shouldn't have the model's tool choice. actually this
254+
could be fine.
255+
1. Tool call service should take in the full chat history since if the model's
256+
tool choice is provided then the last mesage is just the tool choice action
257+
by the main subagent loop.
258+
1. When tool service makes a tool call, that should be reflected in the UI. In
259+
general, subagent services should be reflected in the UI.
260+
261+
<!-- For routing -->
262+
263+
If ollama hasn't started then this error comes out from routing:
264+
http://gpaste/5701046179594240
256265

257266
# Litellm setup
258267

0 commit comments

Comments
 (0)