fix(canvas): Agent 模型调用 - 修复关闭思考被误判为开启
This commit is contained in:
@@ -135,7 +135,7 @@ func (s *Service) runCloudAgentModelStep(ctx context.Context, userID, runID stri
|
||||
},
|
||||
"textOptions": map[string]any{
|
||||
"stream": true,
|
||||
"thinking": thinkingLevel != "off",
|
||||
"thinking": cloudAgentPiThinkingEnabled(thinkingLevel),
|
||||
"maxOutputTokens": cloudAgentStepOutputBudget(state.StepLimits, state.BoostStepOutputBudget),
|
||||
},
|
||||
}
|
||||
@@ -198,6 +198,13 @@ func (s *Service) runCloudAgentModelStep(ctx context.Context, userID, runID stri
|
||||
return map[string]any{"text": result.Text, "reasoning": result.Reasoning, "toolCalls": runtimeToolCalls(result.ToolCalls)}, false, nil
|
||||
}
|
||||
|
||||
// cloudAgentPiThinkingEnabled treats an omitted thinking level the same as Pi's
|
||||
// explicit "off" value. Pi omits the field when thinking is disabled, and the
|
||||
// Go JSON decoder represents that omitted field as an empty string.
|
||||
func cloudAgentPiThinkingEnabled(thinkingLevel string) bool {
|
||||
return thinkingLevel != "" && thinkingLevel != "off"
|
||||
}
|
||||
|
||||
// cloudAgentModelTaskRetryable 按上游真实 HTTP 状态判断失败是否是临时性的:
|
||||
// 5xx、429、408 与没有拿到任何响应的网络错误可以重试;空回复也可以重试。
|
||||
// 其余 4xx(参数、鉴权、模型不存在)重试结果不会变,直接失败。
|
||||
|
||||
Reference in New Issue
Block a user