Ask Stop hooks whether the turn should keep going. Forces at most one * continuation per turn (stop_hook_active) so a hook can't loop forever.
()
| 430 | /** Ask Stop hooks whether the turn should keep going. Forces at most one |
| 431 | * continuation per turn (stop_hook_active) so a hook can't loop forever. */ |
| 432 | private async shouldContinueAfterStop(): Promise<boolean> { |
| 433 | if (!this.hooks.hasHooks("Stop")) return false |
| 434 | const result = await this.hooks.run("Stop", { stop_hook_active: this.stopHookActive }) |
| 435 | if (result.stopAll) return false |
| 436 | if (result.blocked && !this.stopHookActive) { |
| 437 | this.stopHookActive = true |
| 438 | const reason = result.blockReason || "A Stop hook asked you to keep going." |
| 439 | this.messages.push({ role: "user", content: `System reminder (Stop hook): ${reason}` }) |
| 440 | return true |
| 441 | } |
| 442 | return false |
| 443 | } |
| 444 | |
| 445 | /** Track a fire-and-forget hook promise so it can be awaited on exit. */ |
| 446 | private trackBackground(p: Promise<unknown>): void { |