强 schema 清洗:所有工具定义在生成时统一清洗,补齐 properties、规整 type、强制 additionalProperties=false,避免 schema 漏洞导致模型随意输出。AITool.cs、ToolSchemaSanitizer.cs
预执行拦截(Claude Code 风格):工具执行前校验 JSON、必填字段、类型、未知字段;失败则返回错误 ToolResult 反馈给模型,允许自修正或降级回复。ToolCallValidator.cs、AIIntelligenceCore.cs 重试清洗:retry_tools 解析前剥离 json 围栏,避免误判。AIIntelligenceCore.cs 工具选择:Query 阶段强制 tool_choice: "required",Action 维持 auto。AIIntelligenceCore.cs
This commit is contained in:
@@ -1909,21 +1909,33 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
var historyManager = Find.World?.GetComponent<AIHistoryManager>();
|
||||
|
||||
|
||||
|
||||
historyManager?.SaveHistory(_activeEventDefName, _history);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
catch (Exception ex)
|
||||
|
||||
|
||||
@@ -4431,7 +4443,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
if (string.IsNullOrWhiteSpace(cleaned))
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
@@ -4521,7 +4533,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5081,6 +5093,20 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
|
||||
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sb.AppendLine($"{role}: {message}");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5863,3 +5889,11 @@ private async Task<PhaseExecutionResult> ExecuteJsonToolsForPhase(string json, R
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
|
||||
sb.Append("{\"facts\":[");
|
||||
|
||||
Reference in New Issue
Block a user