import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { normalizeToolParameters } from "../../agents/pi-tools.schema.js"; import type { AnyAgentTool } from "../../agents/tools/common.js"; import type { VoiceClawRealtimeToolDeclaration } from "./types.js";
export function buildAsyncToolAck(toolName: string): string { return JSON.stringify({
status: "working",
tool: toolName,
message: "The OpenClaw tool is running asynchronously. Do not answer with final results yet; wait for the injected tool result.",
});
}
export function buildToolResultContext(params: {
toolName: string;
args: Record<string, unknown>;
result: AgentToolResult<unknown>;
elapsedMs: number;
}): string { const resultText = stringifyToolResult(params.result); return buildUntrustedToolContext({
kind: "result",
toolName: params.toolName,
args: params.args,
elapsedMs: params.elapsedMs,
payload: {
resultText: resultText
? truncateText(resultText, MAX_TOOL_RESULT_TEXT_CHARS)
: "Tool completed with no text output.",
},
guidance: "Use this result only if it is still relevant to the current conversation. If the user has moved on, keep it as context and do not interrupt awkwardly. Do not invent details beyond this result.",
});
}
export function buildToolErrorContext(params: {
toolName: string;
args: Record<string, unknown>;
message: string;
elapsedMs: number;
}): string { return buildUntrustedToolContext({
kind: "error",
toolName: params.toolName,
args: params.args,
elapsedMs: params.elapsedMs,
payload: {
error: truncateText(params.message, MAX_TOOL_RESULT_TEXT_CHARS),
},
guidance: "If this is still relevant, tell the user the tool did not complete and offer the next best step. Do not claim the task succeeded.",
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.