feat: add toolCallId to ExecutionLogEntry for precise frontend matching
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
107069ea06
commit
e4ba9f78b1
@@ -392,6 +392,7 @@ export async function toolExecutorNode(
|
||||
statusList.push({ tool: name, status: "error", message: blockReason });
|
||||
executionLog.push({
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: "error",
|
||||
summary: blockReason,
|
||||
timestamp: Date.now(),
|
||||
@@ -467,6 +468,7 @@ export async function toolExecutorNode(
|
||||
});
|
||||
const fallbackLogEntry: ExecutionLogEntry = {
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: "fallback_success",
|
||||
summary: `知识库不可用,回退到网络搜索,获取 ${fallbackResults.length} 条结果`,
|
||||
timestamp: Date.now(),
|
||||
@@ -494,6 +496,7 @@ export async function toolExecutorNode(
|
||||
statusList.push({ tool: name, status: "error", message: formatToolError(name, kbError) });
|
||||
const dblFailEntry: ExecutionLogEntry = {
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: "error",
|
||||
summary: "知识库及网络搜索均不可用",
|
||||
timestamp: Date.now(),
|
||||
@@ -605,6 +608,7 @@ export async function toolExecutorNode(
|
||||
}
|
||||
const kbLogEntry: ExecutionLogEntry = {
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: results.length === 0 ? "partial_success" : "success",
|
||||
summary: execSummary,
|
||||
timestamp: Date.now(),
|
||||
@@ -732,7 +736,7 @@ export async function toolExecutorNode(
|
||||
|
||||
if (tickets.length === 0) {
|
||||
statusList.push({ tool: name, status: "empty", message: "未查询到工单" });
|
||||
const tlEmptyEntry: ExecutionLogEntry = { tool: name, status: "partial_success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`page: ${parsed.page ?? 1}`), durationMs: Date.now() - startTime, resultCount: 0, retryCount: tlRetryCount };
|
||||
const tlEmptyEntry: ExecutionLogEntry = { tool: name, toolCallId: id, status: "partial_success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`page: ${parsed.page ?? 1}`), durationMs: Date.now() - startTime, resultCount: 0, retryCount: tlRetryCount };
|
||||
executionLog.push(tlEmptyEntry);
|
||||
logToolCall(tlEmptyEntry);
|
||||
return {
|
||||
@@ -749,7 +753,7 @@ export async function toolExecutorNode(
|
||||
};
|
||||
}
|
||||
statusList.push({ tool: name, status: "ok" });
|
||||
const tlOkEntry: ExecutionLogEntry = { tool: name, status: "success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`page: ${parsed.page ?? 1}`), durationMs: Date.now() - startTime, resultCount: tickets.length, retryCount: tlRetryCount };
|
||||
const tlOkEntry: ExecutionLogEntry = { tool: name, toolCallId: id, status: "success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`page: ${parsed.page ?? 1}`), durationMs: Date.now() - startTime, resultCount: tickets.length, retryCount: tlRetryCount };
|
||||
executionLog.push(tlOkEntry);
|
||||
logToolCall(tlOkEntry);
|
||||
return {
|
||||
@@ -797,7 +801,7 @@ export async function toolExecutorNode(
|
||||
{ message: lastAiMessage },
|
||||
);
|
||||
statusList.push({ tool: name, status: "ok" });
|
||||
const tdOkEntry: ExecutionLogEntry = { tool: name, status: "success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`ticket_id: ${parsed.ticket_id}`), durationMs: Date.now() - startTime, resultCount: 1, retryCount: tdRetryCount };
|
||||
const tdOkEntry: ExecutionLogEntry = { tool: name, toolCallId: id, status: "success", summary: execSummary, timestamp: Date.now(), inputSummary: truncateInput(`ticket_id: ${parsed.ticket_id}`), durationMs: Date.now() - startTime, resultCount: 1, retryCount: tdRetryCount };
|
||||
executionLog.push(tdOkEntry);
|
||||
logToolCall(tdOkEntry);
|
||||
return {
|
||||
@@ -847,6 +851,7 @@ export async function toolExecutorNode(
|
||||
statusList.push({ tool: name, status: "ok" });
|
||||
const chartLogEntry: ExecutionLogEntry = {
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: "success",
|
||||
summary: `图表已生成:${parsed.title}`,
|
||||
timestamp: Date.now(),
|
||||
@@ -877,6 +882,7 @@ export async function toolExecutorNode(
|
||||
const argsStr = typeof args === "object" ? JSON.stringify(args) : String(args);
|
||||
const errLogEntry: ExecutionLogEntry = {
|
||||
tool: name,
|
||||
toolCallId: id,
|
||||
status: "error",
|
||||
summary: friendlyError,
|
||||
timestamp: Date.now(),
|
||||
|
||||
@@ -20,6 +20,8 @@ export type ToolStatus =
|
||||
*/
|
||||
export type ExecutionLogEntry = {
|
||||
tool: string;
|
||||
/** Corresponds to LLM tool_call.id for precise frontend matching */
|
||||
toolCallId?: string;
|
||||
status: ToolStatus;
|
||||
timestamp: number;
|
||||
durationMs: number;
|
||||
|
||||
Reference in New Issue
Block a user