fix(odin): dedupe tool-trace chips — one per tool, warning only if all attempts failed
A failed call followed by a successful retry showed two identical chips (one orange). Retries are loop mechanics: the trace now carries one entry per tool with ok = delivered-at-least-once, for live chips and persisted history alike (also keeps meta.tools under its 30-entry cap). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -381,6 +381,17 @@ export async function agenticChat(
|
||||
}
|
||||
}
|
||||
|
||||
// One chip per tool: a failed attempt followed by a successful retry is
|
||||
// loop mechanics, not information for the user. ok = the tool delivered
|
||||
// data at least once; orange stays only when every attempt failed. Also
|
||||
// keeps the persisted meta.tools comfortably under its 30-entry cap.
|
||||
const dedupedTrace: ToolTraceEntry[] = [];
|
||||
for (const t of trace) {
|
||||
const seen = dedupedTrace.find((d) => d.name === t.name);
|
||||
if (!seen) dedupedTrace.push({ ...t });
|
||||
else seen.ok = seen.ok || t.ok;
|
||||
}
|
||||
|
||||
const text = (res?.content ?? [])
|
||||
.filter((b): b is Anthropic.TextBlock => b.type === "text")
|
||||
.map((b) => b.text)
|
||||
@@ -399,7 +410,7 @@ export async function agenticChat(
|
||||
} else if (!reply) {
|
||||
reply = "Nepodařilo se získat odpověď, zkuste to prosím znovu.";
|
||||
}
|
||||
return { reply, toolTrace: trace };
|
||||
return { reply, toolTrace: dedupedTrace };
|
||||
}
|
||||
|
||||
export interface ExtractedInvoice {
|
||||
|
||||
Reference in New Issue
Block a user