feat(agentcli): 运行结果 incomplete 语义与契约文档
RunResult 增加 Outcome/Reason;触顶标记 incomplete:max_steps; WebSocket finish 区分 incomplete 与 fatal error。补充 ai-agent docs 13 与挂点索引。
This commit is contained in:
1 parent
f3a4fb569f
commit
1c98c25c74
9 files changed
+249
-6
No files matched your search
@@ -78,6 +78,9 @@ type RunResult struct {
|
||||
Output string
|
||||
History []llm.Message // system 之后的对话历史
|
||||
TotalTokens int
|
||||
// Outcome/Reason 对齐三产品契约(completed/incomplete/...) // Logan.Li
|
||||
Outcome string
|
||||
Reason string
|
||||
}
|
||||
|
||||
// Config Agent 运行配置 // Logan.Li
|
||||
@@ -237,8 +240,7 @@ func (a *Agent) Run(ctx context.Context, query, serverInfo string, prior []llm.M
|
||||
a.emit(Event{Type: EventDone, Phase: PhaseDone, Answer: answer, Tokens: a.totalTokens})
|
||||
a.triggerEvolve(ctx, query, serverInfo, answer, toolRecords, true, start)
|
||||
return &RunResult{
|
||||
Success: true, Output: answer,
|
||||
History: a.extractHistory(messages), TotalTokens: a.totalTokens,
|
||||
Success: true, Output: answer, Outcome: "completed", History: a.extractHistory(messages), TotalTokens: a.totalTokens,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -255,12 +257,13 @@ func (a *Agent) Run(ctx context.Context, query, serverInfo string, prior []llm.M
|
||||
consecutiveFailures = a.updateConsecutiveFailures(observations, consecutiveFailures) + failInc
|
||||
}
|
||||
|
||||
// 达到最大轮次
|
||||
msg := fmt.Sprintf("达到最大迭代次数(%d),任务未能完成。可能任务过于复杂或需要更多步骤。", a.config.MaxIterations)
|
||||
// 达到最大轮次 → incomplete:max_steps(契约 13) // Logan.Li
|
||||
msg := fmt.Sprintf("incomplete:max_steps: 达到最大迭代次数(%d),任务未完成。可加大预算或 continueTask 续跑。", a.config.MaxIterations)
|
||||
a.emit(Event{Type: EventError, Phase: PhaseError, Message: msg, Tokens: a.totalTokens})
|
||||
a.triggerEvolve(ctx, query, serverInfo, "", toolRecords, false, start)
|
||||
return &RunResult{
|
||||
Success: false, History: a.extractHistory(messages), TotalTokens: a.totalTokens,
|
||||
Success: false, Output: msg, History: a.extractHistory(messages), TotalTokens: a.totalTokens,
|
||||
Outcome: "incomplete", Reason: "max_steps",
|
||||
}, fmt.Errorf("%s", msg)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user