d33becd877
_handle_active_session_busy_message (the busy_session_handler most platform adapters register) demotes busy_input_mode='interrupt' to queue semantics for two reasons: active subagents (#30170) and, as of this week, context compression in flight (#56391) — interrupting while compression holds the state.db lock races a new turn against the pre-rotation parent session, and if that new turn also grows past the compression threshold it starts its own uncancellable compression on the same stale parent, forking orphaned compression siblings. _handle_message has its own, independent inline "PRIORITY" busy-path (reached directly with a live running agent — see the `if _quick_key in self._running_agents:` guard, exercised end-to-end by the existing tests/gateway/test_running_agent_session_toggles.py harness). Its own comment says it mirrors _handle_active_session_busy_message's subagent- demotion rationale verbatim, and it does demote for active subagents, but it never checked _session_has_compression_in_flight, so a plain-text follow-up landing on this path while compression is mid-flight still called running_agent.interrupt() unconditionally. Fix: add the same _session_has_compression_in_flight(session_key) check before the PRIORITY interrupt call, demoting to queue exactly like the sibling path. Tests: tests/gateway/test_priority_path_compression_demotion_56391.py drives _handle_message end-to-end (reusing the test_running_agent_ session_toggles.py harness pattern) with a live running agent and a mocked compression lock. Mutation-verified: reverting the fix makes the demotion test fail (interrupt() gets called) against the pre-fix code; a control test pins the unchanged default-interrupt behavior when no compression lock is held.