1003
? Math.max(0, (params.turn.completedAt - params.turn.startedAt) * 1000)
1004
: typeof fallbackDuration === 'number' && Number.isFinite(fallbackDuration)
1006
: 0;
1007
const orphanedToolCallActions: (SessionAction | ChatAction)[] = orphanedToolCalls.map(entry => ({
1009
>
turnId: entry.turnId,
1010
>
toolCallId: entry.toolCallId,
1011
>
result: {
1012
>
success: false,
1013
>
pastTenseMessage: `Stopped ${entry.toolName}`,
1014
>
content: entry.output ? [{ type: ToolResultContentType.Text as const, text: entry.output }] : undefined,
1015
>
error: { message: status === 'interrupted' ? 'Turn interrupted before the tool completed' : 'Turn completed before the tool reported completion' },
1016
>
},
1017
}));
1018
if (status === 'failed' && params.turn.error) {