| 1718 | |
| 1719 | describe('Tool request retries', () => { |
| 1720 | function makeJsonResponse( |
| 1721 | status: number, |
| 1722 | body: unknown, |
| 1723 | extraHeaders?: Record<string, string> |
| 1724 | ): any { |
| 1725 | const headers = new Headers({ 'content-type': 'application/json', ...(extraHeaders ?? {}) }) |
| 1726 | return { |
| 1727 | ok: status >= 200 && status < 300, |
| 1728 | status, |
| 1729 | statusText: status >= 200 && status < 300 ? 'OK' : 'Error', |
| 1730 | headers, |
| 1731 | json: () => Promise.resolve(body), |
| 1732 | text: () => Promise.resolve(typeof body === 'string' ? body : JSON.stringify(body)), |
| 1733 | arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)), |
| 1734 | blob: () => Promise.resolve(new Blob()), |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | it('retries on 5xx responses for http_request', async () => { |
| 1739 | global.fetch = Object.assign( |