( storedData: NormalizedData, requestBody: string | undefined, workDir: string, toolResultNormalizers: ToolResultNormalizer[], )
| 673 | } |
| 674 | |
| 675 | async function findSavedChatCompletionError( |
| 676 | storedData: NormalizedData, |
| 677 | requestBody: string | undefined, |
| 678 | workDir: string, |
| 679 | toolResultNormalizers: ToolResultNormalizer[], |
| 680 | ): Promise<NormalizedErrorResponse | undefined> { |
| 681 | const normalized = await parseAndNormalizeRequest( |
| 682 | requestBody, |
| 683 | workDir, |
| 684 | toolResultNormalizers, |
| 685 | ); |
| 686 | const requestMessages = normalized.conversations[0]?.messages ?? []; |
| 687 | const requestModel = normalized.models[0]; |
| 688 | |
| 689 | for (const error of storedData.errors ?? []) { |
| 690 | if (error.model && error.model !== requestModel) { |
| 691 | continue; |
| 692 | } |
| 693 | if ( |
| 694 | requestMessages.length === error.messages.length && |
| 695 | requestMessages.every( |
| 696 | (msg, i) => JSON.stringify(msg) === JSON.stringify(error.messages[i]), |
| 697 | ) |
| 698 | ) { |
| 699 | return error; |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | return undefined; |
| 704 | } |
| 705 | |
| 706 | // Checks if the request matches a snapshot that has no assistant response. |
| 707 | // This handles timeout test scenarios where the snapshot only records the request. |
no test coverage detected
searching dependent graphs…