fix(delegate-task): add subagent turn limit and model routing transparency
原因:
- subagent 无最大步数限制,陷入 tool-call 死循环时可无限运行,造成巨额 API 费用
- category 路由将 subagent 静默切换到与父 session 不同的模型,用户完全无感知
改动:
- sync-session-poller: 新增 maxAssistantTurns 参数(默认 300),每检测到新 assistant 消息
计数一次,超限后调用 abortSyncSession 并返回明确错误信息
- sync-task: task 完成时在返回字符串中显示实际使用的模型;若与父 session 模型不同,
加 ⚠️ 警告提示用户发生了静默路由
影响:
- 现有行为不变,maxAssistantTurns 为可选参数,默认值 300 远高于正常任务所需轮次
- 修复 #2571:用户一个下午因 Sisyphus-Junior 死循环 + 静默路由到 Gemini 3.1 Pro
烧掉 $350+,且 OpenCode 显示费用仅为实际的一半
This commit is contained in:
@@ -149,9 +149,23 @@ export async function executeSyncTask(
|
||||
|
||||
const duration = formatDuration(startTime)
|
||||
|
||||
// 检测模型路由是否与父 session 不同,给用户可见的提示
|
||||
const actualModelStr = categoryModel
|
||||
? `${categoryModel.providerID}/${categoryModel.modelID}`
|
||||
: undefined
|
||||
const parentModelStr = parentContext.model
|
||||
? `${parentContext.model.providerID}/${parentContext.model.modelID}`
|
||||
: undefined
|
||||
const modelRoutingNote =
|
||||
actualModelStr && parentModelStr && actualModelStr !== parentModelStr
|
||||
? `\n⚠️ Model routing: parent used ${parentModelStr}, this subagent used ${actualModelStr} (via category: ${args.category ?? "unknown"})`
|
||||
: actualModelStr
|
||||
? `\nModel: ${actualModelStr}${args.category ? ` (category: ${args.category})` : ""}`
|
||||
: ""
|
||||
|
||||
return `Task completed in ${duration}.
|
||||
|
||||
Agent: ${agentToUse}${args.category ? ` (category: ${args.category})` : ""}
|
||||
Agent: ${agentToUse}${args.category ? ` (category: ${args.category})` : ""}${modelRoutingNote}
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user