You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
interrupt can take a long time, it should be immediate #428
autonomous: likelyProbably hands-off: clearly worth fixing, agent can do it, minor judgment needed.bugSomething isn't workingpriority: highP1 - important bug or impactful feature, fix soon
Using deepseek v4 flash from opencode go, sometimes I find myself waiting for quite a bit after pressing 'esc' while the model goes off on a tangent, pressing repeatedly or doing ctrl+c doesn't help either. On an rare occasion esc works quickly.
I think it should really be immediate.
The TUI can get quite slow after a while and when under load from the model pouring text, through I don't think this is the reason for interruption not to work because the TUI does acknowledge it quickly, then the acknowledgement indicator soon disappears though so not really sure.
Investigated the full cancel path end to end and landed a hardening fix on master in bda54d8.
How cancel works today: Esc sends Request::Cancel, which the server dispatches before writing the Ack (so heavy streaming can't delay it), fires the session's lock-free InterruptSignal, waits 500ms for cooperative exit, then hard-aborts the turn task (crates/jcode-app-core/src/server/client_lifecycle.rs:2737). The agent's stream loop and tool-wait select both park on InterruptSignal::notified() (crates/jcode-app-core/src/agent/turn_streaming_mpsc.rs:328,1282).
What we found:InterruptSignal::notified() (crates/jcode-agent-runtime/src/lib.rs) created the tokio Notified future and checked the fired flag before awaiting. Notify::notify_waiters() wakes only registered waiters and stores no permit, so any gap in registration loses the wakeup entirely - and a lost wakeup there parks the cancel path until an unrelated event (e.g. the next stream token or keepalive) arrives, which matches your symptom of the interrupt being acknowledged and then apparently ignored. The future is now explicitly enable()d before the flag check, with a 2000-iteration race-hammer regression test plus a test pinning the tokio semantics.
Also worth noting: several interrupt-path fixes landed since the commit you reported on (381306e), including pre-Ack cancel dispatch and a lock-free cancel handle for busy sessions.
Could you retest on the next release (or a master build)? If Esc still takes long, the server logs now have detailed SERVER_INTERRUPT_* timing lines (in ~/.jcode/logs/) - a snippet from around a slow interrupt would pinpoint any remaining latency precisely.
Tried 7b90fd6 which contains commits you mentioned and it seems much the same: pressing esc while model outputs thinking content leads to "Interrupting ..." appearing for 3-4s just above the prompt line then disappearing, after this it is as if nothing happened, the model keeps going at full speed. Eventually when it does stop, "Interrupted [xN]" appears (N happened to be 66 this time).
Landed a deeper fix on master in 9c1ca3e1 (merged in e2a50251), directly from your log evidence.
Root cause found: your logs showed SERVER_INTERRUPT_CANCEL_NO_LOCAL_TASK with has_task=false on every Esc. The cancel was firing the InterruptSignal held by your connection's control handle, but after a reattach/reload (or for server-initiated and headless turns) that signal can be a different instance from the graceful_shutdown signal the streaming turn actually polls. Firing the stale instance did nothing, so the client showed "Interrupting..." while the model kept generating, and each extra Esc just stacked another Interrupted [xN].
Fix: a process-global turn cancel registry. Every turn registers its own cancel signal at turn start (RAII, auto-unregistered and reset when the turn ends), and request_cancel now fans out to every registered signal for the session in addition to its own handle. So the cancel reaches the in-flight provider stream no matter which handle instance received it. New log line to look for: SESSION_CANCEL_ACTIVE_TURN_SIGNALS_FIRED.
Validated with a regression test reproducing exactly your scenario (streaming turn + stale control-handle signal, cancel must abort promptly). Would appreciate a retest on a build containing 9c1ca3e1 next time you're on deepseek via opencode go.
autonomous: likelyProbably hands-off: clearly worth fixing, agent can do it, minor judgment needed.bugSomething isn't workingpriority: highP1 - important bug or impactful feature, fix soon
Activity
dmt4 commentedon Jun 30, 2026
Forgot to say, version used was git commit 381306e, however it has been an issue for a while.
fix(runtime): make InterruptSignal::notified() registration explicit …
1jehuang commentedon Jul 3, 2026
Investigated the full cancel path end to end and landed a hardening fix on master in bda54d8.
How cancel works today: Esc sends
Request::Cancel, which the server dispatches before writing the Ack (so heavy streaming can't delay it), fires the session's lock-freeInterruptSignal, waits 500ms for cooperative exit, then hard-aborts the turn task (crates/jcode-app-core/src/server/client_lifecycle.rs:2737). The agent's stream loop and tool-wait select both park onInterruptSignal::notified()(crates/jcode-app-core/src/agent/turn_streaming_mpsc.rs:328,1282).What we found:
InterruptSignal::notified()(crates/jcode-agent-runtime/src/lib.rs) created the tokioNotifiedfuture and checked the fired flag before awaiting.Notify::notify_waiters()wakes only registered waiters and stores no permit, so any gap in registration loses the wakeup entirely - and a lost wakeup there parks the cancel path until an unrelated event (e.g. the next stream token or keepalive) arrives, which matches your symptom of the interrupt being acknowledged and then apparently ignored. The future is now explicitlyenable()d before the flag check, with a 2000-iteration race-hammer regression test plus a test pinning the tokio semantics.Also worth noting: several interrupt-path fixes landed since the commit you reported on (381306e), including pre-Ack cancel dispatch and a lock-free cancel handle for busy sessions.
Could you retest on the next release (or a master build)? If Esc still takes long, the server logs now have detailed
SERVER_INTERRUPT_*timing lines (in~/.jcode/logs/) - a snippet from around a slow interrupt would pinpoint any remaining latency precisely.fix(server): epoch-guard deferred cancel resets so rapid Esc presses …
dmt4 commentedon Jul 4, 2026
Tried 7b90fd6 which contains commits you mentioned and it seems much the same: pressing esc while model outputs thinking content leads to "Interrupting ..." appearing for 3-4s just above the prompt line then disappearing, after this it is as if nothing happened, the model keeps going at full speed. Eventually when it does stop, "Interrupted [xN]" appears (N happened to be 66 this time).
The log has this repeating ~N times:
then at the end when it finally stopped there are ~N of these:
notice the it took ~7-8min. In this time the agent was spewing thinking content, calling tools etc..
fix(server): fan out cancels to all active turn signals via turn canc…
1jehuang commentedon Jul 4, 2026
Landed a deeper fix on master in 9c1ca3e1 (merged in e2a50251), directly from your log evidence.
Root cause found: your logs showed
SERVER_INTERRUPT_CANCEL_NO_LOCAL_TASKwithhas_task=falseon every Esc. The cancel was firing theInterruptSignalheld by your connection's control handle, but after a reattach/reload (or for server-initiated and headless turns) that signal can be a different instance from thegraceful_shutdownsignal the streaming turn actually polls. Firing the stale instance did nothing, so the client showed "Interrupting..." while the model kept generating, and each extra Esc just stacked anotherInterrupted [xN].Fix: a process-global turn cancel registry. Every turn registers its own cancel signal at turn start (RAII, auto-unregistered and reset when the turn ends), and
request_cancelnow fans out to every registered signal for the session in addition to its own handle. So the cancel reaches the in-flight provider stream no matter which handle instance received it. New log line to look for:SESSION_CANCEL_ACTIVE_TURN_SIGNALS_FIRED.Validated with a regression test reproducing exactly your scenario (streaming turn + stale control-handle signal, cancel must abort promptly). Would appreciate a retest on a build containing 9c1ca3e1 next time you're on deepseek via opencode go.
dmt4 commentedon Jul 4, 2026
Just fetched and don't see 9c1ca3e1 neither e2a50251.
I think is not specific to opencode go or ds4 flash, today was running gemma4 31b myself and was the same story.
1jehuang commentedon Jul 7, 2026
Released in v0.37.0. Run
jcode updateto get it.10 remaining items
tui: render LaTeX images off the draw path (1jehuang#735)
fix(interrupt): migrate turn cancel registry on session rename (fixes 1…
tui: render LaTeX images off the draw path (1jehuang#735)
fix(runtime): make InterruptSignal::notified() registration explicit …
fix(server): epoch-guard deferred cancel resets so rapid Esc presses …
fix(server): fan out cancels to all active turn signals via turn canc…
fix(interrupt): migrate turn cancel registry on session rename (fixes 1…
tui: render LaTeX images off the draw path (1jehuang#735)
fix(interrupt): migrate turn cancel registry on session rename (fixes 1…
tui: render LaTeX images off the draw path (1jehuang#735)
fix(interrupt): migrate turn cancel registry on session rename (fixes 1…
tui: render LaTeX images off the draw path (1jehuang#735)
fix(interrupt): migrate turn cancel registry on session rename (fixes 1…
tui: render LaTeX images off the draw path (1jehuang#735)
Tag jade relay and debug-socket injects as UserExternal too