| 643 | // nothing irreversible has happened yet; the one thing we can't undo is an |
| 644 | // already-committed reasoning row, so we decline the restart in that case. |
| 645 | const rollbackForRetry = (): boolean => { |
| 646 | if (reasoningRowCommitted) return false |
| 647 | assistantText = "" |
| 648 | reasoningOpen = false |
| 649 | reasoningStart = 0 |
| 650 | reasoningDetails = undefined |
| 651 | toolCallsByIndex.clear() |
| 652 | nextSyntheticIndex = 10000 |
| 653 | onEvent({ type: "stream-reset" }) |
| 654 | return true |
| 655 | } |
| 656 | |
| 657 | const stream = this.streamWithRetry( |
| 658 | () => this.client.createMessage(this.systemPrompt, this.outgoingMessages(), getActiveTools(this.mcp), signal), |