Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(codex): fork active threads without rollback RPC (#2169)
Call Whitee6249e7ae64c
diff --git a/core/session_turns.py b/core/session_turns.pyindex 435f94a2d..bfefd6093 100644--- a/core/session_turns.py+++ b/core/session_turns.py@@ -7737,6 +7737,7 @@ class SessionTurnManager:entry = self.in_flight.get(session_id)active = entry is not None and not entry.task.done()native_turn_started = False+ native_turn_id: str | None = Noneactive_turn_id: str | None = Nonebackend = ""backend_alive: Optional[bool] = None@@ -7781,11 +7782,25 @@ class SessionTurnManager:try:with self._sqlite_engine().begin() as conn:pending_input_count = len(delivery_store.list_queued(conn, session_id))+ if active and self._durable_schema_available():+ durable_turn = delivery_store.active_turn(conn, session_id)+ if (+ durable_turn is not None+ and str(durable_turn["id"]) == str(active_turn_id or "")+ ):+ native_turn_id = (+ str(durable_turn.get("native_turn_id") or "").strip()+ or None+ )if not active and self._durable_schema_available():durable_turn = delivery_store.active_turn(conn, session_id)if durable_turn is not None:active = Trueactive_turn_id = str(durable_turn["id"])+ native_turn_id = (+ str(durable_turn.get("native_turn_id") or "").strip()+ or None+ )native_turn_started = durable_turn["state"] == "active"backend = str(durable_turn.get("backend") or "").strip()initial = delivery_store.delivery_for_turn(@@ -7891,6 +7906,8 @@ class SessionTurnManager:}if backend:result["backend"] = backend+ if native_turn_id:+ result["native_turn_id"] = native_turn_idif owner is not None:result["owner"] = ownerif active and active_turn_id:@@ -7901,6 +7918,44 @@ class SessionTurnManager:result["model_recovery"] = recoveryreturn result+ def native_turn_id_for_initial_message(+ self,+ session_id: str,+ message_id: str,+ ) -> str | None:+ """Return the persisted native turn id for one turn's initial message."""++ normalized_session_id = str(session_id or "").strip()+ normalized_message_id = str(message_id or "").strip()+ if not normalized_session_id or not normalized_message_id:+ return None+ try:+ with self._sqlite_engine().connect() as conn:+ row = conn.execute(+ select(session_turn_rows.c.native_turn_id)+ .select_from(+ session_turn_rows.join(+ delivery_rows,+ session_turn_rows.c.initial_delivery_id == delivery_rows.c.id,+ )+ )+ .where(session_turn_rows.c.session_id == normalized_session_id)+ .where(delivery_rows.c.message_id == normalized_message_id)+ .order_by(+ session_turn_rows.c.created_at.desc(),+ session_turn_rows.c.id.desc(),+ )+ .limit(1)+ ).mappings().first()+ except Exception:+ logger.debug(+ "Failed to read native turn id for initial message %s",+ normalized_message_id,+ exc_info=True,+ )+ return None+ return str((row or {}).get("native_turn_id") or "").strip() or None+async def release_for_service_shutdown(self) -> int:"""Fail exact accepted Run owners without draining replacement work."""diff --git a/modules/agents/codex/agent.py b/modules/agents/codex/agent.pyindex 2571e4e92..55db850d4 100644--- a/modules/agents/codex/agent.py+++ b/modules/agents/codex/agent.py@@ -133,6 +133,10 @@ class CodexPromptRefreshUnavailableError(RuntimeError):"""The current app-server cannot safely refresh a persisted thread prompt."""+class CodexForkBoundaryUnavailableError(RuntimeError):+ """The source history cannot prove a safe inclusive fork boundary."""++class CodexResumeUnavailableError(RuntimeError):"""The Codex thread associated with this session can no longer be resumed.@@ -1477,6 +1481,12 @@ class CodexAgent(BaseAgent):or "en")message = i18n_t("error.codexPromptRefreshUnavailable", language)+ elif isinstance(error, CodexForkBoundaryUnavailableError):+ language = str(+ getattr(getattr(self.controller, "config", None), "language", "en")+ or "en"+ )+ message = i18n_t("error.codexForkBoundaryUnavailable", language)else:message = f"Codex error: {error}"@@ -2596,6 +2606,7 @@ class CodexAgent(BaseAgent):source_thread_id = str(fork.get("source_native_session_id") or "").strip()params: Dict[str, Any] = {"threadId": source_thread_id,+ "excludeTurns": True,"cwd": request.working_path,"approvalPolicy": "never","sandbox": "danger-full-access",@@ -2621,7 +2632,27 @@ class CodexAgent(BaseAgent):self._mark_fork_correction_pending(request.base_session_id)try:- should_trim = await self._should_rollback_forked_running_turn(fork)+ should_trim = await self._should_trim_forked_running_turn(fork)+ if should_trim:+ source_still_running, last_completed_turn_id = (+ await self._fork_source_last_completed_turn_id(transport, fork)+ )+ if not last_completed_turn_id:+ raise CodexForkBoundaryUnavailableError(+ "Cannot fork Codex thread while the source turn boundary "+ "is unknown"+ )+ # `lastTurnId` is the stable thread/fork boundary supported by+ # the Codex app-server versions Avibe supports. It is+ # inclusive: use the preceding terminal turn while the source+ # is active, or the source turn itself if it completed during+ # this race.+ params["lastTurnId"] = last_completed_turn_id+ if not source_still_running:+ logger.debug(+ "Codex source turn completed during fork boundary read; "+ "preserving completed history"+ )resp = await transport.send_request("thread/fork", params)thread_id = resp.get("id", "")if not thread_id:@@ -2631,8 +2662,6 @@ class CodexAgent(BaseAgent):if not thread_id:raise RuntimeError("Codex thread/fork returned no thread id")- if should_trim:- await self._rollback_forked_running_turn(transport, thread_id)await self._inject_forked_session_correction(transport, request, thread_id)finally:self._clear_fork_correction_pending(request.base_session_id)@@ -2714,8 +2743,8 @@ class CodexAgent(BaseAgent):logger.info("Forked Codex thread %s from %s for session %s", thread_id, source_thread_id, request.base_session_id)return thread_id- async def _should_rollback_forked_running_turn(self, fork: dict[str, Any]) -> bool:- """Rollback only when Codex's latest-turn rollback still targets the reserved turn."""+ async def _should_trim_forked_running_turn(self, fork: dict[str, Any]) -> bool:+ """Trim only when the reserved fork boundary still targets this turn."""if not bool(fork.get("trim_latest_running_turn")):return False@@ -2753,20 +2782,127 @@ class CodexAgent(BaseAgent):body = turn_result.get("body") or {}return bool(body.get("in_flight") and body.get("native_turn_started"))- async def _rollback_forked_running_turn(+ async def _fork_source_native_turn_id(self, fork: dict[str, Any]) -> Optional[str]:+ """Return the active native turn at the source fork boundary."""++ source_session_id = str(fork.get("source_session_id") or "").strip()+ if not source_session_id:+ return None++ turn_registry = getattr(self, "_turn_registry", None)+ get_active_turn = getattr(turn_registry, "get_active_turn", None)+ if callable(get_active_turn):+ native_turn_id = str(get_active_turn(source_session_id) or "").strip()+ if native_turn_id:+ return native_turn_id++ source_message_id = str(fork.get("source_message_id") or "").strip()+ session_turns = getattr(getattr(self, "controller", None), "session_turns", None)+ get_for_initial_message = getattr(+ session_turns,+ "native_turn_id_for_initial_message",+ None,+ )+ if source_message_id and callable(get_for_initial_message):+ try:+ native_turn_id = str(+ get_for_initial_message(source_session_id, source_message_id) or ""+ ).strip()+ except Exception:+ logger.debug(+ "Could not read persisted Codex fork boundary for session %s",+ source_session_id,+ exc_info=True,+ )+ else:+ if native_turn_id:+ return native_turn_id++ from vibe import internal_client++ try:+ turn_result = await internal_client.turn_state(source_session_id)+ except (internal_client.InternalServerTimeout, internal_client.InternalServerUnavailable):+ return None+ body = turn_result.get("body") or {}+ if not (body.get("in_flight") and body.get("native_turn_started")):+ return None+ return str(body.get("native_turn_id") or "").strip() or None++ async def _fork_source_last_completed_turn_id(self,transport: CodexTransport,- thread_id: str,- ) -> None:- """Remove the source's still-running latest turn from a forked thread."""+ fork: dict[str, Any],+ ) -> tuple[bool, Optional[str]]:+ """Resolve the inclusive fork boundary immediately before a live turn.++ ``thread/fork.lastTurnId`` cannot point at an in-progress turn. Page+ through the source turns in reverse chronological order and return the+ preceding terminal turn instead. If the reserved turn completed during+ this race, use that turn itself: ``lastTurnId`` is inclusive, so this+ still excludes any later turn that may have started while the fork+ request was being prepared.+ """- await transport.send_request(- "thread/rollback",- {- "threadId": thread_id,- "numTurns": 1,- },- )+ active_turn_id = await self._fork_source_native_turn_id(fork)+ source_thread_id = str(fork.get("source_native_session_id") or "").strip()+ if not active_turn_id or not source_thread_id:+ return True, None++ cursor: Optional[str] = None+ seen_cursors: set[str] = set()+ active_turn_seen = False+ try:+ while True:+ params: dict[str, Any] = {+ "threadId": source_thread_id,+ "limit": 2,+ "itemsView": "notLoaded",+ "sortDirection": "desc",+ }+ if cursor:+ params["cursor"] = cursor+ response = await transport.send_request("thread/turns/list", params)++ turns = response.get("data") if isinstance(response, dict) else None+ if not isinstance(turns, list):+ return True, None++ for turn in turns:+ if not isinstance(turn, dict):+ return True, None+ turn_id = str(turn.get("id") or "").strip()+ status = str(turn.get("status") or "").strip()+ if turn_id == active_turn_id:+ if status in {"completed", "interrupted", "failed"}:+ return False, active_turn_id+ if status != "inProgress":+ return True, None+ active_turn_seen = True+ elif active_turn_seen:+ # Descending pages contain the predecessor after the+ # active turn, possibly on the next page. Do not skip+ # an unproven boundary and silently discard history.+ if not turn_id or status not in {"completed", "interrupted", "failed"}:+ return True, None+ return True, turn_id++ next_cursor = response.get("nextCursor")+ if (+ not isinstance(next_cursor, str)+ or not next_cursor+ or next_cursor in seen_cursors+ ):+ return True, None+ seen_cursors.add(next_cursor)+ cursor = next_cursor+ except (CodexRPCError, CodexResponseTooLargeError, ConnectionError, TimeoutError):+ logger.debug(+ "Could not read Codex fork boundary for source thread %s",+ source_thread_id,+ exc_info=True,+ )+ return True, Nonedef _resolve_codex_agent_settings(self,diff --git a/tests/test_codex_agent.py b/tests/test_codex_agent.pyindex 6f3c5d621..3d736e97a 100644--- a/tests/test_codex_agent.py+++ b/tests/test_codex_agent.py@@ -36,6 +36,21 @@ def _catalog_reference(path):catalog.retain = Mock(return_value=catalog)return catalog++def _fork_transport():+ def send_request(method, _params):+ if method == "thread/turns/list":+ return {+ "data": [+ {"id": "turn-source", "status": "inProgress"},+ {"id": "turn-before", "status": "completed"},+ ],+ }+ return {"thread": {"id": "thread-fork"}}++ return SimpleNamespace(send_request=AsyncMock(side_effect=send_request))++_modules_pkg = types.ModuleType("modules")_agents_pkg = types.ModuleType("modules.agents")_codex_pkg = types.ModuleType("modules.agents.codex")@@ -180,6 +195,7 @@ CodexConnectionProbeRuntimeMismatchError = (_MODULE.CodexConnectionProbeRuntimeMismatchError)CodexPromptRefreshUnavailableError = _MODULE.CodexPromptRefreshUnavailableError+CodexForkBoundaryUnavailableError = _MODULE.CodexForkBoundaryUnavailableErrorCodexResumeUnavailableError = _MODULE.CodexResumeUnavailableErrorfor name, module in _saved_modules.items():@@ -1599,6 +1615,66 @@ class CodexAgentHandleMessageTests(unittest.IsolatedAsyncioTestCase):"❌ Codex 无法确认能否安全刷新此现有会话的 Avibe 指令。请检查或升级 Codex 后重试本回合。",)+ async def test_handle_message_localizes_fork_boundary_failure(self):+ messages = {+ "en": (+ "❌ Codex could not determine a safe history boundary for this fork. "+ "Wait for the source turn to finish, then retry. "+ "If the problem persists, check or update Codex."+ ),+ "zh": (+ "❌ Codex 无法确定此次分叉的安全历史边界。"+ "请等待源会话当前回合结束后重试;如果问题持续,请检查或升级 Codex。"+ ),+ }+ for language, expected in messages.items():+ with self.subTest(language=language):+ agent = object.__new__(CodexAgent)+ context = SimpleNamespace(platform_specific={})+ request = SimpleNamespace(+ base_session_id="session-1",+ working_path="/tmp/work",+ context=context,+ session_key="settings-1",+ ack_message_id=None,+ )+ transport = SimpleNamespace(stop=AsyncMock())+ agent.controller = SimpleNamespace(+ config=SimpleNamespace(language=language),+ emit_agent_message=AsyncMock(),+ )+ agent.sessions = SimpleNamespace()+ agent._session_locks = {}+ agent._turn_registry = _HandleMessageTurnRegistry(active_turn=None)+ agent._session_mgr = SimpleNamespace(+ set_session_key=Mock(), set_cwd=Mock(), get_thread_id=Mock(return_value=None),+ )+ agent._get_or_create_transport = AsyncMock(return_value=transport)+ agent._touch_transport_activity = Mock()+ agent._delete_ack = AsyncMock()+ agent._remove_ack_reaction = AsyncMock()+ agent._event_handler = SimpleNamespace(_release_stream_turn=Mock())+ agent._build_thread_developer_instructions = AsyncMock(return_value="prompt")+ diagnostic = "Cannot fork Codex thread while the source turn boundary is unknown"+ agent._start_or_resume_thread = AsyncMock(+ side_effect=CodexForkBoundaryUnavailableError(diagnostic),+ )+ agent._start_turn = AsyncMock()+ agent._drop_transport_after_failure = AsyncMock()++ await agent.handle_message(request)++ calls = agent.controller.emit_agent_message.await_args_list+ self.assertEqual(len(calls), 2)+ self.assertEqual(calls[0].args, (context, "notify", expected))+ self.assertNotIn(diagnostic, calls[0].args[2])+ self.assertIn(diagnostic, calls[1].kwargs["terminal_error"])+ agent._start_or_resume_thread.assert_awaited_once()+ agent._start_turn.assert_not_awaited()+ agent._drop_transport_after_failure.assert_not_awaited()+ transport.stop.assert_not_awaited()+ agent._event_handler._release_stream_turn.assert_called_once_with(context)+async def test_handle_message_does_not_hide_turn_before_interrupt_succeeds(self):agent = object.__new__(CodexAgent)request = SimpleNamespace(@@ -2570,6 +2646,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):method, params = transport.send_request.await_args_list[0].argsself.assertEqual(method, "thread/fork")self.assertEqual(params["threadId"], "thread-source")+ self.assertTrue(params["excludeTurns"])self.assertEqual(params["cwd"], "/tmp/work")self.assertEqual(params["approvalPolicy"], "never")self.assertEqual(params["sandbox"], "danger-full-access")@@ -2688,7 +2765,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):agent._inject_caller_env_config = Mock(return_value=("path-state", True))agent._mark_fork_correction_pending = Mock()agent._clear_fork_correction_pending = Mock()- agent._should_rollback_forked_running_turn = AsyncMock(return_value=False)+ agent._should_trim_forked_running_turn = AsyncMock(return_value=False)agent._inject_forked_session_correction = AsyncMock()agent._session_mgr = SimpleNamespace(set_thread_id=Mock())agent.bind_agent_session_id = Mock(return_value="ses-target")@@ -2740,7 +2817,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):agent._inject_caller_env_config = Mock(return_value=("path-state", True))agent._mark_fork_correction_pending = Mock()agent._clear_fork_correction_pending = Mock()- agent._should_rollback_forked_running_turn = AsyncMock(return_value=False)+ agent._should_trim_forked_running_turn = AsyncMock(return_value=False)agent._inject_forked_session_correction = AsyncMock()agent._session_mgr = SimpleNamespace(set_thread_id=Mock())agent.bind_agent_session_id = Mock(return_value="ses-target")@@ -2785,7 +2862,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):agent._inject_caller_env_config = Mock(return_value=("path-state", True))agent._mark_fork_correction_pending = Mock()agent._clear_fork_correction_pending = Mock()- agent._should_rollback_forked_running_turn = AsyncMock(return_value=False)+ agent._should_trim_forked_running_turn = AsyncMock(return_value=False)agent._inject_forked_session_correction = AsyncMock()agent._session_mgr = SimpleNamespace(set_thread_id=Mock())agent.bind_agent_session_id = Mock(return_value="ses-target")@@ -2866,7 +2943,325 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):agent.sessions.bind_agent_session.assert_not_called()self.assertFalse(agent.is_fork_correction_pending("ses-target"))- async def test_start_or_resume_thread_rolls_back_running_fork_before_correction(self):+ async def test_fork_rejects_trim_without_native_turn_boundary(self):+ agent = object.__new__(CodexAgent)+ agent.controller = SimpleNamespace(+ config=SimpleNamespace(platform="avibe", reply_enhancements=False),+ session_turns=SimpleNamespace(+ native_turn_id_for_initial_message=Mock(return_value=None),+ ),+ )+ agent.codex_config = SimpleNamespace(default_model=None)+ agent.sessions = SimpleNamespace(+ get_agent_session_id=Mock(return_value=None),+ ensure_agent_session_id=Mock(return_value="ses-target"),+ bind_agent_session=Mock(return_value="ses-target"),+ )+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value=None),+ )+ agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._fork_correction_pending_base_sessions = set()+ agent._fork_source_prompt_state = Mock(return_value=(None, None, None))+ agent._resolve_codex_agent_settings = Mock(+ return_value=(None, None, None, None),+ )+ agent._inject_caller_env_config = Mock(return_value=("", False))+ agent._should_trim_forked_running_turn = AsyncMock(return_value=True)+ agent._mark_fork_correction_pending = Mock()+ agent._clear_fork_correction_pending = Mock()+ request = SimpleNamespace(+ working_path="/tmp/work",+ context=SimpleNamespace(platform_specific={}),+ base_session_id="ses-target",+ session_key="avibe::project::proj_1",+ )+ transport = SimpleNamespace(send_request=AsyncMock())++ with patch(+ "vibe.internal_client.turn_state",+ new=AsyncMock(+ return_value={+ "body": {+ "in_flight": True,+ "native_turn_started": True,+ }+ }+ ),+ ):+ with self.assertRaisesRegex(+ CodexForkBoundaryUnavailableError, "source turn boundary is unknown"+ ):+ await agent._fork_thread(+ transport,+ request,+ {+ "source_session_id": "ses-source",+ "source_native_session_id": "thread-source",+ "source_message_id": "msg-source",+ "trim_latest_running_turn": True,+ },+ )++ transport.send_request.assert_not_awaited()+ agent._clear_fork_correction_pending.assert_called_once_with("ses-target")++ async def test_fork_boundary_requires_a_completed_predecessor(self):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source"),+ )+ transport = SimpleNamespace(+ send_request=AsyncMock(+ return_value={+ "data": [+ {"id": "turn-source", "status": "inProgress"},+ ],+ }+ )+ )++ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {+ "source_session_id": "ses-source",+ "source_native_session_id": "thread-source",+ },+ )++ self.assertEqual(boundary, (True, None))+ transport.send_request.assert_awaited_once_with(+ "thread/turns/list",+ {+ "threadId": "thread-source",+ "limit": 2,+ "itemsView": "notLoaded",+ "sortDirection": "desc",+ },+ )++ async def test_fork_boundary_keeps_completed_reserved_turn_inclusive(self):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source"),+ )+ transport = SimpleNamespace(+ send_request=AsyncMock(+ return_value={+ "data": [+ {"id": "turn-new", "status": "inProgress"},+ {"id": "turn-source", "status": "completed"},+ ],+ }+ )+ )++ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {+ "source_session_id": "ses-source",+ "source_native_session_id": "thread-source",+ },+ )++ self.assertEqual(boundary, (False, "turn-source"))+ transport.send_request.assert_awaited_once_with(+ "thread/turns/list",+ {+ "threadId": "thread-source",+ "limit": 2,+ "itemsView": "notLoaded",+ "sortDirection": "desc",+ },+ )++ async def test_fork_keeps_boundary_when_source_completes_before_rpc_write(self):+ for status in ("completed", "interrupted", "failed"):+ with self.subTest(status=status):+ agent = object.__new__(CodexAgent)+ agent.sessions = SimpleNamespace(+ ensure_agent_session_id=Mock(return_value="ses-target"),+ bind_agent_session=Mock(return_value="ses-target"),+ )+ agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source"),+ )+ agent._fork_source_prompt_state = Mock(return_value=(None, None, None))+ agent._resolve_codex_agent_settings = Mock(return_value=(None, None, None, None))+ agent._inject_caller_env_config = Mock(return_value=("", False))+ agent._should_trim_forked_running_turn = AsyncMock(return_value=True)+ agent._inject_forked_session_correction = AsyncMock()+ agent._mark_fork_correction_pending = Mock()+ agent._clear_fork_correction_pending = Mock()+ request = SimpleNamespace(+ working_path="/tmp/work",+ context=SimpleNamespace(platform_specific={}),+ base_session_id="ses-target",+ session_key="avibe::project::proj_1",+ )++ async def send_request(method, params):+ if method == "thread/turns/list":+ self.assertEqual(params["itemsView"], "notLoaded")+ self.assertEqual(params["limit"], 2)+ return {"data": [{"id": "turn-source", "status": status}]}+ self.assertEqual(method, "thread/fork")+ # A queued turn starts during the RPC write, after the+ # boundary read. The fork must retain the completed source+ # turn but must not copy this new active turn.+ await asyncio.sleep(0)+ agent._turn_registry.get_active_turn.return_value = "turn-next"+ self.assertEqual(params["lastTurnId"], "turn-source")+ self.assertTrue(params["excludeTurns"])+ return {"thread": {"id": "thread-fork"}}++ transport = SimpleNamespace(send_request=AsyncMock(side_effect=send_request))+ thread_id = await agent._fork_thread(+ transport,+ request,+ {+ "source_session_id": "ses-source",+ "source_native_session_id": "thread-source",+ "trim_latest_running_turn": True,+ },+ )+ self.assertEqual(thread_id, "thread-fork")+ self.assertEqual(transport.send_request.await_count, 2)+ agent.sessions.bind_agent_session.assert_called_once()+ agent._inject_forked_session_correction.assert_awaited_once_with(+ transport, request, "thread-fork"+ )++ async def test_fork_boundary_pages_to_find_terminal_predecessor(self):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source"),+ )+ transport = SimpleNamespace(+ send_request=AsyncMock(+ side_effect=[+ {+ "data": [+ {"id": "turn-source", "status": "inProgress"},+ ],+ "nextCursor": "older",+ },+ {+ "data": [+ {"id": "turn-before", "status": "completed"},+ ],+ "nextCursor": None,+ },+ ]+ )+ )++ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {+ "source_session_id": "ses-source",+ "source_native_session_id": "thread-source",+ },+ )++ self.assertEqual(boundary, (True, "turn-before"))+ self.assertEqual(+ transport.send_request.await_args_list,+ [+ call(+ "thread/turns/list",+ {+ "threadId": "thread-source",+ "limit": 2,+ "itemsView": "notLoaded",+ "sortDirection": "desc",+ },+ ),+ call(+ "thread/turns/list",+ {+ "threadId": "thread-source",+ "limit": 2,+ "itemsView": "notLoaded",+ "sortDirection": "desc",+ "cursor": "older",+ },+ ),+ ],+ )++ async def test_fork_boundary_searches_older_pages_for_reserved_turn(self):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(get_active_turn=Mock(return_value="turn-source"))+ transport = SimpleNamespace(+ send_request=AsyncMock(+ side_effect=[+ {+ "data": [+ {"id": "turn-next", "status": "inProgress"},+ {"id": "turn-later", "status": "completed"},+ ],+ "nextCursor": "older",+ },+ {"data": [{"id": "turn-source", "status": "completed"}]},+ ]+ )+ )+ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {"source_session_id": "ses-source", "source_native_session_id": "thread-source"},+ )+ self.assertEqual(boundary, (False, "turn-source"))+ self.assertEqual(transport.send_request.await_count, 2)+ self.assertEqual(transport.send_request.await_args.args[1]["cursor"], "older")++ async def test_fork_boundary_rejects_unproven_history(self):+ responses = [+ None,+ {},+ {"data": {}},+ {"data": []},+ {"data": [{"id": "other", "status": "completed"}]},+ {"data": [{"id": "turn-source", "status": "unknown"}]},+ {+ "data": [+ {"id": "turn-source", "status": "inProgress"},+ {"id": "turn-before", "status": "unknown"},+ ],+ },+ {"data": [None]},+ CodexRPCError({"code": -32601, "message": "unsupported"}),+ CodexResponseTooLargeError(),+ ConnectionError("disconnected"),+ TimeoutError("timed out"),+ ]+ for response in responses:+ with self.subTest(response=response):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(get_active_turn=Mock(return_value="turn-source"))+ transport = SimpleNamespace(send_request=AsyncMock(side_effect=[response]))+ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {"source_session_id": "ses-source", "source_native_session_id": "thread-source"},+ )+ self.assertEqual(boundary, (True, None))+ transport.send_request.assert_awaited_once()++ async def test_fork_boundary_rejects_repeated_pagination_cursor(self):+ agent = object.__new__(CodexAgent)+ agent._turn_registry = SimpleNamespace(get_active_turn=Mock(return_value="turn-source"))+ transport = SimpleNamespace(+ send_request=AsyncMock(return_value={"data": [], "nextCursor": "same"}),+ )+ boundary = await agent._fork_source_last_completed_turn_id(+ transport,+ {"source_session_id": "ses-source", "source_native_session_id": "thread-source"},+ )+ self.assertEqual(boundary, (True, None))+ self.assertEqual(transport.send_request.await_count, 2)++ async def test_start_or_resume_thread_trims_running_fork_before_correction(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -2876,6 +3271,9 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):bind_agent_session=Mock(return_value="ses-target"),)agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source")+ )agent._fork_correction_pending_base_sessions = set()request = SimpleNamespace(working_path="/tmp/work",@@ -2907,18 +3305,20 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()thread_id = await agent._start_or_resume_thread(transport, request)self.assertEqual(thread_id, "thread-fork")self.assertEqual([call.args[0] for call in transport.send_request.await_args_list], [+ "thread/turns/list","thread/fork",- "thread/rollback","thread/inject_items",])- rollback_params = transport.send_request.await_args_list[1].args[1]- self.assertEqual(rollback_params, {"threadId": "thread-fork", "numTurns": 1})+ self.assertEqual(+ transport.send_request.await_args_list[1].args[1]["lastTurnId"],+ "turn-before",+ )agent.sessions.bind_agent_session.assert_called_once_with("avibe::project::proj_1","codex",@@ -2926,7 +3326,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):"thread-fork",)- async def test_start_or_resume_thread_skips_running_fork_rollback_before_native_start(self):+ async def test_start_or_resume_thread_keeps_running_fork_before_native_start(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -2967,7 +3367,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()with patch("vibe.internal_client.turn_state",@@ -2981,7 +3381,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):"thread/inject_items",])- async def test_start_or_resume_thread_rolls_back_pre_start_fork_after_source_started(self):+ async def test_start_or_resume_thread_trims_pre_start_fork_after_source_started(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3028,9 +3428,22 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):async def turn_state(_source_session_id):nonlocal turn_state_checkedturn_state_checked = True- return {"body": {"in_flight": True, "native_turn_started": True}}+ return {+ "body": {+ "in_flight": True,+ "native_turn_started": True,+ "native_turn_id": "turn-source",+ }+ }- async def send_request(method, params):+ def send_request(method, _params):+ if method == "thread/turns/list":+ return {+ "data": [+ {"id": "turn-source", "status": "inProgress"},+ {"id": "turn-before", "status": "completed"},+ ],+ }if method == "thread/fork":self.assertTrue(turn_state_checked)return {"thread": {"id": "thread-fork"}}@@ -3045,12 +3458,14 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(thread_id, "thread-fork")self.assertEqual([call.args[0] for call in transport.send_request.await_args_list], [+ "thread/turns/list","thread/fork",- "thread/rollback","thread/inject_items",])+ fork_params = transport.send_request.await_args_list[1].args[1]+ self.assertEqual(fork_params["lastTurnId"], "turn-before")- async def test_start_or_resume_thread_rolls_back_pre_start_fork_after_source_output(self):+ async def test_start_or_resume_thread_trims_pre_start_fork_after_source_output(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3060,6 +3475,9 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):bind_agent_session=Mock(return_value="ses-target"),)agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source")+ )agent._fork_correction_pending_base_sessions = set()request = SimpleNamespace(working_path="/tmp/work",@@ -3092,7 +3510,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()with patch.object(_MODULE,@@ -3109,14 +3527,14 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(thread_id, "thread-fork")self.assertEqual([call.args[0] for call in transport.send_request.await_args_list], [+ "thread/turns/list","thread/fork",- "thread/rollback","thread/inject_items",])- rollback_params = transport.send_request.await_args_list[1].args[1]- self.assertEqual(rollback_params, {"threadId": "thread-fork", "numTurns": 1})+ fork_params = transport.send_request.await_args_list[1].args[1]+ self.assertEqual(fork_params["lastTurnId"], "turn-before")- async def test_start_or_resume_thread_skips_running_fork_rollback_when_anchor_completed(self):+ async def test_start_or_resume_thread_keeps_running_fork_when_anchor_completed(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3126,6 +3544,9 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):bind_agent_session=Mock(return_value="ses-target"),)agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source")+ )agent._fork_correction_pending_base_sessions = set()request = SimpleNamespace(working_path="/tmp/work",@@ -3158,7 +3579,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()with patch.object(_MODULE,@@ -3179,7 +3600,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):"thread/inject_items",])- async def test_start_or_resume_thread_skips_running_fork_rollback_after_source_completed(self):+ async def test_start_or_resume_thread_keeps_running_fork_after_source_completed(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3242,7 +3663,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):"thread/inject_items",])- async def test_start_or_resume_thread_rolls_back_reserved_user_anchor_after_source_completed(self):+ async def test_start_or_resume_thread_trims_reserved_user_anchor_after_source_completed(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3252,6 +3673,9 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):bind_agent_session=Mock(return_value="ses-target"),)agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source")+ )agent._fork_correction_pending_base_sessions = set()request = SimpleNamespace(working_path="/tmp/work",@@ -3284,7 +3708,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()with patch.object(_MODULE,@@ -3303,14 +3727,14 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(thread_id, "thread-fork")self.assertEqual([call.args[0] for call in transport.send_request.await_args_list], [+ "thread/turns/list","thread/fork",- "thread/rollback","thread/inject_items",])- rollback_params = transport.send_request.await_args_list[1].args[1]- self.assertEqual(rollback_params, {"threadId": "thread-fork", "numTurns": 1})+ fork_params = transport.send_request.await_args_list[1].args[1]+ self.assertEqual(fork_params["lastTurnId"], "turn-before")- async def test_start_or_resume_thread_rolls_back_user_anchor_completed_before_native_start_flag(self):+ async def test_start_or_resume_thread_trims_user_anchor_completed_before_native_start_flag(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3320,6 +3744,9 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):bind_agent_session=Mock(return_value="ses-target"),)agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent._turn_registry = SimpleNamespace(+ get_active_turn=Mock(return_value="turn-source")+ )agent._fork_correction_pending_base_sessions = set()request = SimpleNamespace(working_path="/tmp/work",@@ -3352,7 +3779,7 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):vibe_agent_model=None,vibe_agent_reasoning_effort=None,)- transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-fork"}}))+ transport = _fork_transport()with patch.object(_MODULE,@@ -3372,12 +3799,14 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(thread_id, "thread-fork")self.assertEqual([call.args[0] for call in transport.send_request.await_args_list], [+ "thread/turns/list","thread/fork",- "thread/rollback","thread/inject_items",])+ fork_params = transport.send_request.await_args_list[1].args[1]+ self.assertEqual(fork_params["lastTurnId"], "turn-before")- async def test_start_or_resume_thread_does_not_roll_back_when_new_user_after_anchor(self):+ async def test_start_or_resume_thread_does_not_trim_when_new_user_after_anchor(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -3464,11 +3893,11 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):has_input_turn_after_anchor=False,),):- should_rollback = await agent._should_rollback_forked_running_turn(fork)+ should_trim = await agent._should_trim_forked_running_turn(fork)- self.assertTrue(should_rollback)+ self.assertTrue(should_trim)- async def test_start_or_resume_thread_does_not_roll_back_user_anchor_before_native_start(self):+ async def test_start_or_resume_thread_does_not_trim_user_anchor_before_native_start(self):agent = object.__new__(CodexAgent)agent.controller = SimpleNamespace(config=SimpleNamespace(platform="avibe", reply_enhancements=False))agent.codex_config = SimpleNamespace(default_model=None)@@ -6340,7 +6769,7 @@ class CodexPromptSnapshotRecoveryTests(unittest.IsolatedAsyncioTestCase):thread_id = "thread-1"if forked:agent._inject_caller_env_config = Mock(return_value=("path", True))- agent._should_rollback_forked_running_turn = AsyncMock(return_value=False)+ agent._should_trim_forked_running_turn = AsyncMock(return_value=False)agent._inject_forked_session_correction = AsyncMock()agent._session_mgr = SimpleNamespace(set_thread_id=Mock())agent.bind_agent_session_id = Mock(return_value="ses-runtime")diff --git a/tests/test_codex_native_prompt_baseline.py b/tests/test_codex_native_prompt_baseline.pyindex 6e6552f87..16f5d1855 100644--- a/tests/test_codex_native_prompt_baseline.py+++ b/tests/test_codex_native_prompt_baseline.py@@ -158,7 +158,7 @@ async def test_fork_sets_target_baseline_but_inherits_source_history_identity():marker = {}agent = _agent(marker)agent._fork_source_prompt_state = Mock(return_value=("fallback", agent._prompt_fingerprint(PROMPT_A), PROMPT_A))- agent._should_rollback_forked_running_turn = AsyncMock(return_value=False)+ agent._should_trim_forked_running_turn = AsyncMock(return_value=False)agent._inject_forked_session_correction = AsyncMock()agent._mark_fork_correction_pending = Mock()agent._clear_fork_correction_pending = Mock()diff --git a/tests/test_codex_prompt_delivery_contract.py b/tests/test_codex_prompt_delivery_contract.pyindex 9ec7f1b27..dfa994f81 100644--- a/tests/test_codex_prompt_delivery_contract.py+++ b/tests/test_codex_prompt_delivery_contract.py@@ -13,7 +13,7 @@ import osfrom contextlib import asynccontextmanagerfrom pathlib import Pathfrom types import SimpleNamespace-from unittest.mock import Mock+from unittest.mock import AsyncMock, Mockfrom aiohttp import webimport pytest@@ -87,7 +87,12 @@ def _tool_names(tools):async def _native_server(tmp_path, *, configured_instructions=None):requests = []completed = asyncio.Queue()- harness = SimpleNamespace(requests=requests, next_input_tokens=10)+ harness = SimpleNamespace(+ requests=requests,+ next_input_tokens=10,+ response_gate=None,+ response_started=asyncio.Event(),+ )async def responses(request):requests.append(await request.json())@@ -117,6 +122,9 @@ async def _native_server(tmp_path, *, configured_instructions=None):]if compacting:events[1]["item"] = {"type": "compaction", "encrypted_content": "CONTRACT_SUMMARY"}+ if harness.response_gate is not None:+ harness.response_started.set()+ await harness.response_gate.wait()return web.Response(text="".join(f"event: {event['type']}\ndata: {json.dumps(event)}\n\n" for event in events),content_type="text/event-stream",@@ -209,6 +217,8 @@ async def _native_server(tmp_path, *, configured_instructions=None):if not any(item.get("type") == "compaction_trigger" for item in model_request["input"]):assert {"exec_command", "write_stdin"} <= namesfinally:+ if harness.response_gate is not None:+ harness.response_gate.set()await harness.native.stop()server.close()await server.wait_closed()@@ -480,6 +490,68 @@ async def test_native_baseline_survives_auto_compaction_and_cold_promotion(tmp_passert text.count(snapshot) == int(not retention_pressure)[email protected]("source_completed", [False, True])+async def test_native_fork_uses_bounded_inclusive_turn_history(tmp_path, source_completed):+ """A real app-server must honor the boundary, not merely accept a field."""+ async with _native_server(tmp_path) as harness:+ native = harness.native+ request = _request(tmp_path)+ source = _agent({})+ source_id = await source._start_or_resume_thread(native, request)+ preserved = "必须保留的上下文 KEEP-FORK-2168 🧪"+ reserved = "正在执行的输入 RESERVED-FORK-2168"+ for text in (preserved, reserved):+ if text == reserved:+ harness.response_gate = asyncio.Event()+ source._build_input = Mock(return_value=[{"type": "text", "text": text, "text_elements": []}])+ await source._start_turn(native, request, source_id)+ if text == preserved:+ await harness.finish_turn()+ await asyncio.wait_for(harness.response_started.wait(), timeout=30)+ page = await native.send_request(+ "thread/turns/list",+ {"threadId": source_id, "limit": 2, "itemsView": "notLoaded", "sortDirection": "desc"},+ )+ reserved_turn, previous_turn = page["data"]+ assert reserved_turn["status"] == "inProgress"+ assert not reserved_turn["items"]+ assert previous_turn["status"] == "completed"+ if source_completed:+ harness.response_gate.set()+ await harness.finish_turn()++ target = _agent({})+ target._turn_registry.get_active_turn = Mock(return_value=reserved_turn["id"])+ target._should_trim_forked_running_turn = AsyncMock(return_value=True)+ target_id = await target._fork_thread(+ native,+ request,+ {+ "source_session_id": "contract-session",+ "source_native_session_id": source_id,+ "trim_latest_running_turn": True,+ "native_turn_started": True,+ },+ )+ assert target_id != source_id+ fork_page = await native.send_request(+ "thread/turns/list",+ {"threadId": target_id, "limit": 2, "itemsView": "notLoaded", "sortDirection": "desc"},+ )+ boundary = reserved_turn if source_completed else previous_turn+ assert fork_page["data"][0]["id"] == boundary["id"]+ assert len(fork_page["data"]) == (2 if source_completed else 1)+ if not source_completed:+ harness.response_gate.set()+ await harness.finish_turn()+ await target._start_turn(native, request, target_id)+ await harness.finish_turn()+ model_input = json.dumps(harness.requests[-1]["input"], ensure_ascii=False)+ assert preserved in model_input+ assert (reserved in model_input) == source_completed++@pytest.mark.asyncioasync def test_native_fork_receives_target_prompt_before_and_after_compaction(tmp_path):source_prompt = "SOURCE_AGENT:原会话。"diff --git a/tests/test_internal_server.py b/tests/test_internal_server.pyindex 173daabde..fa7b16f55 100644--- a/tests/test_internal_server.py+++ b/tests/test_internal_server.py@@ -2804,6 +2804,7 @@ def test_turn_state_projects_a_restored_durable_owner_without_in_flight(assert state["in_flight"] is Trueassert state["foreground"] == "running"assert state["native_turn_started"] is True+ assert state["native_turn_id"] == f"native:{turn_id}"assert state["backend"] == "opencode"assert state["owner"]["runtime_key"] == f"runtime:{session['id']}"assert state["owner"]["native_turn_started"] is Truediff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex 3501eb856..8b95a72d3 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -424,6 +424,7 @@"claudeSessionNotFound": "Claude Code could not find the historical session `{sessionId}` in the current working directory:\n`{path}`\n\nClaude Code sessions are scoped to a working directory. This usually means the conversation was resumed after switching workdirs, or the local Claude Code session data changed. Restore the original session in its original working directory, then explicitly retry the pending input; or start a new conversation from the current directory.","sessionGeneric": "An error occurred: {error}","codexPromptRefreshUnavailable": "Codex could not confirm that it can safely refresh Avibe's instructions for this existing session. Check or update Codex, then retry this turn.",+ "codexForkBoundaryUnavailable": "Codex could not determine a safe history boundary for this fork. Wait for the source turn to finish, then retry. If the problem persists, check or update Codex.","codexResponseTooLarge": "Codex returned a response larger than {limitMiB} MiB, so this connection cannot continue. Check or update Codex before retrying.","opencodeModelHubOverlayRequired": "OpenCode is still preparing for Gateway mode. Retry in a moment.","opencodePolicyRefreshPending": "OpenCode is still finishing an existing turn and cannot restart with Avibe's current Skill policy yet. Retry after that turn finishes.",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex f40930c19..85585503d 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -424,6 +424,7 @@"claudeSessionNotFound": "Claude Code 在当前工作目录下找不到历史会话 `{sessionId}`:\n`{path}`\n\nClaude Code 的会话和工作目录相关。通常是恢复会话后切换了工作目录,或本地 Claude Code 会话数据发生变化。请在原工作目录恢复原会话,再手动重试待发送的输入;也可以在当前目录开始一个新会话。","sessionGeneric": "发生错误:{error}","codexPromptRefreshUnavailable": "Codex 无法确认能否安全刷新此现有会话的 Avibe 指令。请检查或升级 Codex 后重试本回合。",+ "codexForkBoundaryUnavailable": "Codex 无法确定此次分叉的安全历史边界。请等待源会话当前回合结束后重试;如果问题持续,请检查或升级 Codex。","codexResponseTooLarge": "Codex 返回的响应超过 {limitMiB} MiB,此连接无法继续。请检查或升级 Codex 后重试。","opencodeModelHubOverlayRequired": "OpenCode 仍在准备 Gateway 模式,请稍后重试。","opencodePolicyRefreshPending": "OpenCode 仍在完成已有回合,暂时无法按 Avibe 当前的 Skill 策略重启。请在该回合结束后重试。",