fix: switch system prompt to avoid malformed tool_calls (#650)

* fix: switch system prompt to avoid malformed tool_calls

* fix: circular dependency issue and configurable tool-call style

* fix: regExp issue
This commit is contained in:
Mingholy
2025-09-18 21:10:03 +08:00
committed by GitHub
parent 761833c915
commit 5f68a8b6b3
17 changed files with 2191 additions and 878 deletions

View File

@@ -7,11 +7,7 @@
import type { Content, GenerateContentConfig } from '@google/genai';
import type { GeminiClient } from '../core/client.js';
import type { EditToolParams } from '../tools/edit.js';
import { EditTool } from '../tools/edit.js';
import { WriteFileTool } from '../tools/write-file.js';
import { ReadFileTool } from '../tools/read-file.js';
import { ReadManyFilesTool } from '../tools/read-many-files.js';
import { GrepTool } from '../tools/grep.js';
import { ToolNames } from '../tools/tool-names.js';
import { LruCache } from './LruCache.js';
import { DEFAULT_QWEN_FLASH_MODEL } from '../config/models.js';
import {
@@ -85,14 +81,14 @@ async function findLastEditTimestamp(
const history = (await client.getHistory()) ?? [];
// Tools that may reference the file path in their FunctionResponse `output`.
const toolsInResp = new Set([
WriteFileTool.Name,
EditTool.Name,
ReadManyFilesTool.Name,
GrepTool.Name,
const toolsInResp = new Set<string>([
ToolNames.WRITE_FILE,
ToolNames.EDIT,
ToolNames.READ_MANY_FILES,
ToolNames.GREP,
]);
// Tools that may reference the file path in their FunctionCall `args`.
const toolsInCall = new Set([...toolsInResp, ReadFileTool.Name]);
const toolsInCall = new Set<string>([...toolsInResp, ToolNames.READ_FILE]);
// Iterate backwards to find the most recent relevant action.
for (const entry of history.slice().reverse()) {