simplify background tool info extraction

This commit is contained in:
Adam Weidman
2026-03-09 00:33:52 -04:00
parent 228c978147
commit e17e34d18f
+3 -22
View File
@@ -114,25 +114,6 @@ const SUPPRESSED_TOOL_ERRORS_NOTE =
const LOW_VERBOSITY_FAILURE_NOTE = const LOW_VERBOSITY_FAILURE_NOTE =
'This request failed. Press F12 for diagnostics, or run /settings and change "Error Verbosity" to full for full details.'; 'This request failed. Press F12 for diagnostics, or run /settings and change "Error Verbosity" to full for full details.';
function normalizeBackgroundExecutionId(
data: BackgroundExecutionData,
): number | undefined {
const executionId: unknown = getBackgroundExecutionId(data);
return typeof executionId === 'number' ? executionId : undefined;
}
function normalizeBackgroundCommand(data: BackgroundExecutionData): string | undefined {
const command: unknown = data.command;
return typeof command === 'string' ? command : undefined;
}
function normalizeBackgroundInitialOutput(
data: BackgroundExecutionData,
): string | undefined {
const initialOutput: unknown = data.initialOutput;
return typeof initialOutput === 'string' ? initialOutput : undefined;
}
function getBackgroundedToolInfo( function getBackgroundedToolInfo(
toolCall: TrackedCompletedToolCall | TrackedCancelledToolCall, toolCall: TrackedCompletedToolCall | TrackedCancelledToolCall,
): BackgroundedToolInfo | undefined { ): BackgroundedToolInfo | undefined {
@@ -143,15 +124,15 @@ function getBackgroundedToolInfo(
} }
const data: BackgroundExecutionData = rawData; const data: BackgroundExecutionData = rawData;
const executionId = normalizeBackgroundExecutionId(data); const executionId = getBackgroundExecutionId(data);
if (executionId === undefined) { if (executionId === undefined) {
return undefined; return undefined;
} }
return { return {
executionId, executionId,
command: normalizeBackgroundCommand(data) ?? toolCall.request.name, command: data.command ?? toolCall.request.name,
initialOutput: normalizeBackgroundInitialOutput(data) ?? '', initialOutput: data.initialOutput ?? '',
}; };
} }