Skip to content

Commit 4082ccd

Browse files
committed
fix: use tool kind instead of title for tool call names
The Auggie SDK's title field contains human-readable descriptions like 'Read `/path/to/file`' instead of actual tool names. Use the kind field (read, edit, execute, etc.) which matches OpenAI's expected tool name format.
1 parent 40633bf commit 4082ccd

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/server.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,11 +1125,16 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
11251125
11261126
case 'tool_call': {
11271127
const toolId = update.toolCallId ?? `call_${randomUUID().slice(0, 8)}`;
1128-
const toolName = update.title ?? 'unknown_tool';
1128+
const toolTitle = update.title ?? 'unknown_tool';
11291129
const toolKind = update.kind ?? 'other';
11301130
const toolStatus = update.status ?? 'pending';
11311131
const rawInput = update.rawInput;
11321132
1133+
// Use kind as the tool name since title contains human-readable descriptions
1134+
// like "Read `/path/to/file`" instead of just "read"
1135+
// This matches OpenAI's expected tool name format
1136+
const toolName = toolKind;
1137+
11331138
// Track tool call index
11341139
if (!toolCallIndices.has(toolId)) {
11351140
toolCallIndices.set(toolId, toolCallCounter++);
@@ -1140,7 +1145,7 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
11401145
const args = rawInput ? JSON.stringify(rawInput) : '';
11411146
11421147
console.log(
1143-
`[${requestId}] 🔧 Tool[${String(toolIndex)}]: ${toolName} (${toolKind}) [${toolStatus}]` +
1148+
`[${requestId}] 🔧 Tool[${String(toolIndex)}]: ${toolName} (title: ${toolTitle}) [${toolStatus}]` +
11441149
(args ? ` args=${args.substring(0, 100)}...` : '')
11451150
);
11461151

@@ -1169,6 +1174,7 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
11691174
// Include custom metadata for richer info
11701175
tool_metadata: {
11711176
kind: toolKind,
1177+
title: toolTitle,
11721178
status: toolStatus,
11731179
locations: formatLocations(update.locations),
11741180
},
@@ -1186,10 +1192,14 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
11861192
const toolId = update.toolCallId ?? 'unknown';
11871193
const toolStatus = update.status ?? 'in_progress';
11881194
const toolTitle = update.title;
1195+
const toolKind = update.kind ?? 'other';
11891196
const rawOutput = update.rawOutput;
11901197
const toolContent = update.toolContent;
11911198
const locations = update.locations;
11921199
1200+
// Use kind as the tool name (consistent with tool_call handling)
1201+
const toolName = toolKind;
1202+
11931203
// Get or create tool index
11941204
if (!toolCallIndices.has(toolId)) {
11951205
toolCallIndices.set(toolId, toolCallCounter++);
@@ -1202,7 +1212,7 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
12021212
const locationsText = formatLocations(locations);
12031213
12041214
console.log(
1205-
`[${requestId}] 🔧 Tool[${String(toolIndex)}] Update: ${toolId} [${toolStatus}]` +
1215+
`[${requestId}] 🔧 Tool[${String(toolIndex)}] Update: ${toolName} [${toolStatus}]` +
12061216
(toolTitle ? ` "${toolTitle}"` : '') +
12071217
(locationsText ? ` @${locationsText}` : '') +
12081218
(outputText ? ` output=${outputText.substring(0, 80)}...` : '')
@@ -1225,7 +1235,7 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
12251235
id: toolId,
12261236
type: 'function',
12271237
function: {
1228-
name: toolTitle ?? '',
1238+
name: toolName,
12291239
// Stream output as additional arguments (result info)
12301240
arguments: outputText
12311241
? JSON.stringify({ _result: outputText.substring(0, 500) })
@@ -1234,6 +1244,7 @@ function createStreamCallback(res: ServerResponse, model: string, requestId: str
12341244
},
12351245
],
12361246
tool_metadata: {
1247+
title: toolTitle,
12371248
status: toolStatus,
12381249
locations: locationsText,
12391250
has_content: contentText.length > 0,

0 commit comments

Comments
 (0)