This commit is contained in:
2025-12-31 13:46:49 +08:00
parent 2af305de68
commit 244ba3d354
5 changed files with 362 additions and 35 deletions

View File

@@ -964,6 +964,13 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
return trimmed.Length >= 4;
}
private void AddTraceNote(string note)
{
if (string.IsNullOrWhiteSpace(note)) return;
_history.Add(("trace", note.Trim()));
PersistHistory();
}
private bool IsToolAvailable(string toolName)
{
if (string.IsNullOrWhiteSpace(toolName)) return false;
@@ -1165,6 +1172,10 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
{
continue;
}
if (string.Equals(entry.role, "trace", StringComparison.OrdinalIgnoreCase))
{
continue;
}
if (string.Equals(entry.role, "tool", StringComparison.OrdinalIgnoreCase))
{
if (lastUserIndex != -1 && i > lastUserIndex)
@@ -1886,6 +1897,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
if (LooksLikeNaturalReply(normalizedResponse))
{
toolPhaseReplyCandidate = normalizedResponse;
AddTraceNote(normalizedResponse);
break;
}
@@ -1902,6 +1914,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
if (LooksLikeNaturalReply(normalizedFixed))
{
toolPhaseReplyCandidate = normalizedFixed;
AddTraceNote(normalizedFixed);
}
if (Prefs.DevMode)
{
@@ -1932,6 +1945,24 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
}
}
if (!string.IsNullOrWhiteSpace(parsedSource))
{
string traceText = parsedSource;
if (!string.IsNullOrWhiteSpace(jsonFragment))
{
int idx = traceText.IndexOf(jsonFragment, StringComparison.Ordinal);
if (idx >= 0)
{
traceText = traceText.Remove(idx, jsonFragment.Length);
}
}
traceText = traceText.Trim();
if (LooksLikeNaturalReply(traceText))
{
AddTraceNote(traceText);
}
}
var invalidTools = toolCalls
.Where(c => !IsToolAvailable(c.Name))
.Select(c => c.Name)