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(sessions): drop the old backend's model when a session changes backend (#2930)
Call White28209e62ac51
diff --git a/docs/plans/2026-10-22-session-backend-switch.md b/docs/plans/2026-10-22-session-backend-switch.mdindex 1ea473544..bf10d68da 100644--- a/docs/plans/2026-10-22-session-backend-switch.md+++ b/docs/plans/2026-10-22-session-backend-switch.md@@ -70,6 +70,11 @@ Unbound sessions keep today's behavior.The UPDATE re-asserts the state the decision was made from: same native, samebackend, not running, no unsettled Turn, the same newest Turn, not archived.+A backend change that names no model or reasoning effort resets both, with+their explicit-override marker: they belong to the old backend's catalog, and+the new Agent's defaults apply instead. The Chat header always sends the picked+Agent's pair; this protects API callers that send only the Agent.+A forked session's spent fork source (`fork_source_native_session_id`,`fork_source_backend`) is dropped by the switch, so the emptied native cannotre-arm a native fork or pin the picker to the fork's backend.diff --git a/storage/workbench_sessions_service.py b/storage/workbench_sessions_service.pyindex 9920211a1..0f60f8c6d 100644--- a/storage/workbench_sessions_service.py+++ b/storage/workbench_sessions_service.py@@ -1195,6 +1195,17 @@ def update_session(requested_backend=agent_backend,)+ if backend_changes:+ # A model and effort name one backend's catalog. Moving to another+ # backend without naming new ones must not carry the old pair across+ # (a Claude model on Vibey fails the next turn): reset both, so the new+ # Agent's defaults apply and their explicit-override marker is reconciled+ # below, as the bind-time backend adoption already does.+ if model is _UNSET:+ model = None+ if reasoning_effort is _UNSET:+ reasoning_effort = None+values: dict[str, Any] = {"updated_at": _utc_now_iso()}if bound_switch:full_row = conn.execute(diff --git a/tests/test_core_services_sessions.py b/tests/test_core_services_sessions.pyindex c604e4dcc..64f04e11f 100644--- a/tests/test_core_services_sessions.py+++ b/tests/test_core_services_sessions.py@@ -618,6 +618,49 @@ def test_update_session_backend_is_free_until_native_bind(isolated_state):assert not sessions_service.get_session(conn, sid)["agent_backend"][email protected]("bound", [False, True])+def test_cross_backend_change_drops_the_old_backends_model_unless_one_is_named(isolated_state, bound):+ """A model and effort belong to one backend's catalog. A cross-backend change+ that names none (an API caller sending only the Agent) must not carry the old+ pair over, nor the marker that pins it, or the next turn asks the new backend+ for a model it does not have. Named values are kept; a same-backend Agent+ change keeps the stored pair as before."""++ import json++ engine = create_sqlite_engine()+ with engine.begin() as conn:+ scope_id = _seed_avibe_scope(conn)+ sid = sessions_service.create_session(+ conn, scope_id=scope_id, agent_backend="claude", agent_name="claude"+ )["id"]+ conn.execute(+ agent_sessions.update()+ .where(agent_sessions.c.id == sid)+ .values(+ model="claude-sonnet-5",+ reasoning_effort="high",+ metadata_json=json.dumps({"explicit_setting_overrides": ["model", "reasoning_effort"]}),+ )+ )+ if bound:+ _bind_native(conn, sid, "claude-native")+ watermark = {"runtime_idle_through_turn": ""} if bound else {}++ same_backend = sessions_service.update_session(conn, sid, agent_backend="claude", agent_name="claude-pro")+ assert (same_backend["model"], same_backend["reasoning_effort"]) == ("claude-sonnet-5", "high")++ switched = sessions_service.update_session(conn, sid, agent_backend="vibey", agent_name="vibey", **watermark)+ assert (switched["model"], switched["reasoning_effort"]) == (None, None)+ assert not switched["metadata"].get("explicit_setting_overrides")++ if not bound:+ named = sessions_service.update_session(+ conn, sid, agent_backend="codex", agent_name="codex", model="gpt-5.6", reasoning_effort="low"+ )+ assert (named["model"], named["reasoning_effort"]) == ("gpt-5.6", "low")++def test_update_session_pending_fork_locks_backend_until_native_bind(isolated_state):"""A fork target has no native id yet, but its pending fork metadata pointsat a source native session owned by one backend. Cross-backend changes would