Global registry that tracks and fires cancel signals for currently running turns, ensuring consistent shutdown across sessions and agents. Reuse for any async workflow needing coordinated cancellation.
// Source: https://github.com/1jehuang/jcode | License: MIT | Copyright 2025 Jeremy Huang // Provided via justclaw.it.com; keep this notice with the code. //! Process-global registry of cancel signals for actively running turns. //! //! Why this exists (issue #428): a cancel (Esc) is delivered through whatever //! `SessionControlHandle` the receiving connection happens to hold. That //! handle's stop signal can be a *different* [`InterruptSignal`] instance from //! the `graceful_shutdown` signal of the agent actually streaming the turn: //! //! - re-attach after a reload or disconnect where cleanup removed the //! `shutdown_signals` registration, //! - server-initiated turns (`spawn_tracked_live_turn`, headless recovery, //! swarm wake delivery) running on an agent object the connectio ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key