mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 16:42:25 +00:00
fix(webui): accept end/error phases in tool trace rendering
Tool call events only displayed at phase=start, but progress_hook sends end/error phases after agent execution. Accept all three phases with call_id deduplication to prevent duplicate rendering. Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
d4ade8f680
commit
d7122a13d3
@ -39,12 +39,24 @@ export function formatToolCallTrace(call: unknown): string | null {
|
|||||||
return `${name}()`;
|
return `${name}()`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VALID_PHASES = new Set(["start", "end", "error"]);
|
||||||
|
|
||||||
export function toolTraceLinesFromEvents(events: unknown): string[] {
|
export function toolTraceLinesFromEvents(events: unknown): string[] {
|
||||||
if (!Array.isArray(events)) return [];
|
if (!Array.isArray(events)) return [];
|
||||||
|
const seen = new Set<string>();
|
||||||
return events
|
return events
|
||||||
.filter((event) => {
|
.filter((event) => {
|
||||||
if (!event || typeof event !== "object") return false;
|
if (!event || typeof event !== "object") return false;
|
||||||
return (event as { phase?: unknown }).phase === "start";
|
const phase = (event as { phase?: unknown }).phase;
|
||||||
|
if (!(phase && typeof phase === "string" && VALID_PHASES.has(phase))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const callId = (event as { call_id?: unknown }).call_id;
|
||||||
|
if (callId && typeof callId === "string") {
|
||||||
|
if (seen.has(callId)) return false;
|
||||||
|
seen.add(callId);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
})
|
})
|
||||||
.map(formatToolCallTrace)
|
.map(formatToolCallTrace)
|
||||||
.filter((trace): trace is string => !!trace);
|
.filter((trace): trace is string => !!trace);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user