* Record the terminal outcome of one tool call for the loop-gate. A success (or * any call with a different signature) resets the streak; a failure with the * same signature as the last failure extends it. Called once per call at every * exit — the pre-impl guards call it explicitly before
(signature: string, failed: boolean)
| 793 | * threshold and every further identical repeat keeps being blocked. |
| 794 | */ |
| 795 | private recordLoopGateOutcome(signature: string, failed: boolean): void { |
| 796 | if (!failed) { |
| 797 | this.lastFailedToolCallSignature = undefined; |
| 798 | this.failedToolCallStreak = 0; |
| 799 | return; |
| 800 | } |
| 801 | if (signature === this.lastFailedToolCallSignature) { |
| 802 | this.failedToolCallStreak += 1; |
| 803 | } else { |
| 804 | this.lastFailedToolCallSignature = signature; |
| 805 | this.failedToolCallStreak = 1; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | async writeSyntheticToolResult( |
| 810 | toolUseId: string, |