engine: Stop works in every state, not just between iterations

Stream drops between chunks (+ the pre-first-token wait); pending approvals/questions/plans resolve as interrupted.
Running shell commands die via an executor interrupt hook; skipped tool calls still get results (no orphans).
Also fixes delete_session calling a nonexistent engine.interrupt().
This commit is contained in:
Rohit C Prasad
2026-07-21 23:16:40 -07:00
parent 0bc149fae4
commit f6ad97274d
5 changed files with 307 additions and 15 deletions
+2
View File
@@ -308,6 +308,8 @@ def build_engine(
model=model,
instructions=instructions,
approver=approver,
# Stop kills the in-flight foreground shell command, not just the loop.
interrupt_hooks=[executor.interrupt_now] if executor is not None else None,
max_iterations=(
max_iterations if max_iterations is not None else config.max_iterations
),