The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): retire recovery marker on local stop
Brooklyn Nicholson5c3bfb6da8c9
diff --git a/tui_gateway/methods_session.py b/tui_gateway/methods_session.pyindex 6ff20b63025..3fa3b3aeaa2 100644--- a/tui_gateway/methods_session.py+++ b/tui_gateway/methods_session.py@@ -3411,6 +3411,13 @@ def _(rid, params: dict) -> dict:if err:return err_interrupt_session_turn(str(params.get("session_id") or ""), session)+ # Retire the crash-recovery marker on a confirmed local Stop. Waiting for+ # the run thread's finally leaves a window where a backend exit looks like+ # a crash and session.resume auto-continues the turn the user just stopped.+ # Extra key covers compression rotating session_key mid-turn.+ with session["history_lock"]:+ active_marker_key = str(session.pop("_active_turn_marker_key", "") or "")+ _retire_turn_marker(session, active_marker_key)return _ok(rid, {"status": "interrupted"})diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex fabf3d38822..0fc10e8cd94 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -12857,7 +12857,17 @@ def _run_prompt_submit(marker_attempt = int(session.pop("_auto_continue_attempt", 0) or 0)marker_text = session.pop("_auto_continue_prompt", None) or textif isinstance(marker_text, str) and marker_text.strip():+ # Publish the original key before the disk write so an interrupt+ # racing startup can retire it even if compression rotates the+ # session key later. The post-write cancel check closes the inverse+ # race where Stop lands first and therefore clears no file yet.+ with session["history_lock"]:+ session["_active_turn_marker_key"] = marker_keyrecord_turn_start(marker_home, marker_key, marker_text, attempts=marker_attempt)+ with session["history_lock"]:+ marker_cancelled = bool(session.get("_turn_cancel_requested"))+ if marker_cancelled:+ clear_turn_marker(marker_home, marker_key)try:from tools.approval import (reset_current_session_key,@@ -13679,6 +13689,8 @@ def _run_prompt_submit(if terminal_receipt_committed:_retire_turn_marker(session, marker_key)with session["history_lock"]:+ if session.get("_active_turn_marker_key") == marker_key:+ session.pop("_active_turn_marker_key", None)session.pop("_hosted_room_task", None)session.pop("_auto_continue_scheduled", None)_emit_settled_session_info(sid, session, agent)