Agents: surface tool failures without assistant output

This commit is contained in:
vrknetha
2026-01-18 18:35:03 +05:30
parent e944f21ec0
commit 65710932ff
9 changed files with 124 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ export function buildEmbeddedRunPayloads(params: {
assistantTexts: string[];
toolMetas: ToolMetaEntry[];
lastAssistant: AssistantMessage | undefined;
lastToolError?: { toolName: string; meta?: string; error?: string };
config?: ClawdbotConfig;
sessionKey: string;
verboseLevel?: VerboseLevel;
@@ -155,6 +156,19 @@ export function buildEmbeddedRunPayloads(params: {
});
}
if (replyItems.length === 0 && params.lastToolError) {
const toolSummary = formatToolAggregate(
params.lastToolError.toolName,
params.lastToolError.meta ? [params.lastToolError.meta] : undefined,
{ markdown: useMarkdown },
);
const errorSuffix = params.lastToolError.error ? `: ${params.lastToolError.error}` : "";
replyItems.push({
text: `⚠️ ${toolSummary} failed${errorSuffix}`,
isError: true,
});
}
const hasAudioAsVoiceTag = replyItems.some((item) => item.audioAsVoice);
return replyItems
.map((item) => ({