Skip to content

Commit 0af2489

Browse files
committed
refactor(agent): 重构工具调用相关代码以适配openai v6.2.0
- 将ToolCall类型替换为ChatCompletionMessageToolCall - 统一工具调用结果的消息格式 - 更新openai依赖版本至6.2.0 - 移除调试日志并优化错误处理 - 调整temperature默认值为0以提高稳定性
1 parent 10fb8a2 commit 0af2489

17 files changed

Lines changed: 1385 additions & 1712 deletions

.claude/settings.local.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
"Bash(pnpm add:*)",
2222
"Bash(npx:*)",
2323
"Bash(xargs sed:*)",
24-
"WebFetch(domain:gist.github.com)"
24+
"WebFetch(domain:gist.github.com)",
25+
"Bash(pnpm update:*)",
26+
"WebFetch(domain:jannesklaas.github.io)"
2527
],
2628
"deny": [],
2729
"ask": [],
2830
"additionalDirectories": [
2931
"/Users/bytedance"
3032
]
3133
}
32-
}
34+
}

docs/agentic-loop-implementation-plan.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class AgentLoop extends EventEmitter {
213213
);
214214

215215
// === 4. 检查是否有工具调用 ===
216-
if (!turnResult.tool_calls || turnResult.tool_calls.length === 0) {
216+
if (!turnResult.toolCalls || turnResult.toolCalls.length === 0) {
217217
// 无工具调用,任务完成
218218
return {
219219
success: true,
@@ -228,7 +228,7 @@ export class AgentLoop extends EventEmitter {
228228

229229
// === 5. 循环检测 (Gemini CLI) ===
230230
const loopDetected = await this.loopDetector.detect(
231-
turnResult.tool_calls,
231+
turnResult.toolCalls,
232232
turnsCount,
233233
messages
234234
);
@@ -250,7 +250,7 @@ export class AgentLoop extends EventEmitter {
250250

251251
// === 7. 批量执行工具 (Gemini CLI) ===
252252
const toolResults = await this.executeToolsBatch(
253-
turnResult.tool_calls,
253+
turnResult.toolCalls,
254254
options
255255
);
256256

@@ -613,7 +613,7 @@ interface TurnOptions {
613613

614614
interface TurnResult {
615615
content: string;
616-
tool_calls?: ToolCall[];
616+
toolCalls?: ToolCall[];
617617
usage?: {
618618
promptTokens: number;
619619
completionTokens: number;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"inquirer": "^12.6.3",
109109
"lodash-es": "^4.17.21",
110110
"lowlight": "^3.3.0",
111-
"openai": "^4.103.0",
111+
"openai": "^6.2.0",
112112
"picomatch": "^4.0.3",
113113
"react": "^19.1.1",
114114
"react-dom": "^19.1.1",

0 commit comments

Comments
 (0)