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(tasks): preserve private run and session policy semantics
cyh9eeb98737b4c
diff --git a/storage/alembic/versions/20260522_0003_agent_runs_schema.py b/storage/alembic/versions/20260522_0003_agent_runs_schema.pyindex 3388d45b8..4ba442771 100644--- a/storage/alembic/versions/20260522_0003_agent_runs_schema.py+++ b/storage/alembic/versions/20260522_0003_agent_runs_schema.py@@ -85,7 +85,10 @@ def upgrade() -> None:op.execute('update run_definitions set message = prompt where message is null')op.execute("update run_definitions set session_policy = "- "case when session_id is not null and session_id != '' then 'existing' else 'existing' end "+ "case "+ "when session_id is not null and session_id != '' then 'existing' "+ "when legacy_session_key is not null and legacy_session_key != '' then 'existing' "+ "else null end ""where session_policy is null")op.create_index("ix_run_definitions_type_enabled", "run_definitions", ["definition_type", "enabled"], if_not_exists=True)diff --git a/storage/migrations.py b/storage/migrations.pyindex cc468cd83..2dfa6db68 100644--- a/storage/migrations.py+++ b/storage/migrations.py@@ -250,7 +250,10 @@ def _repair_head_required_columns(conn: sqlite3.Connection, tables: set[str]) ->if "session_policy" in definition_columns:conn.execute('update "run_definitions" set session_policy = '- 'case when session_id is not null and session_id != "" then "existing" else "existing" end '+ 'case '+ 'when session_id is not null and session_id != "" then "existing" '+ 'when legacy_session_key is not null and legacy_session_key != "" then "existing" '+ "else null end "'where session_policy is null')diff --git a/storage/sessions_service.py b/storage/sessions_service.pyindex 5a5570c4a..ec00d1efd 100644--- a/storage/sessions_service.py+++ b/storage/sessions_service.py@@ -113,7 +113,7 @@ class SQLiteSessionsService:scope_id = upsert_scope(conn,platform_key,- "user",+ "channel",native_id,display_name="Private Agent Run",native_type="private_agent_run",diff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.pyindex 3b5dff96b..f5b002516 100644--- a/tests/test_cli_task_command.py+++ b/tests/test_cli_task_command.py@@ -2,6 +2,7 @@ from __future__ import annotationsimport ioimport json+import sqlite3import sysfrom contextlib import redirect_stderrfrom pathlib import Path@@ -798,6 +799,42 @@ def test_agent_run_private_async_reserves_session_and_queues_request(tmp_path: Passert queued["agent_name"] == "worker"+def test_agent_run_private_async_uses_no_delivery_channel_scope_for_lark(tmp_path: Path, capsys) -> None:+ db_path = tmp_path / "state" / "vibe.sqlite"+ agent_store = cli.VibeAgentStore(db_path)+ agent_store.create(name="worker", backend="codex")+ request_store = cli.TaskExecutionStore(tmp_path / "task_requests")+ args = _parse_agent_run(["--agent", "worker", "--async", "--message", "hello"])++ with (+ patch("vibe.cli._agent_store", return_value=agent_store),+ patch("vibe.cli._task_request_store", return_value=request_store),+ patch("vibe.cli.paths.get_sqlite_state_path", return_value=db_path),+ patch("vibe.cli._primary_platform", return_value="lark"),+ ):+ result = cli.cmd_agent_run(args)++ assert result == 0+ payload = json.loads(capsys.readouterr().out)+ with sqlite3.connect(db_path) as conn:+ row = conn.execute(+ """+ select scopes.platform, scopes.scope_type, scopes.native_type, scopes.metadata_json, agent_sessions.metadata_json+ from agent_sessions+ join scopes on scopes.id = agent_sessions.scope_id+ where agent_sessions.id = ?+ """,+ (payload["session_id"],),+ ).fetchone()++ assert row is not None+ assert row[0] == "lark"+ assert row[1] == "channel"+ assert row[2] == "private_agent_run"+ assert json.loads(row[3])["no_delivery"] is True+ assert json.loads(row[4])["no_delivery"] is True++def test_agent_run_rejects_deprecated_prompt_argument(tmp_path: Path) -> None:db_path = tmp_path / "state" / "vibe.sqlite"agent_store = cli.VibeAgentStore(db_path)diff --git a/tests/test_sqlite_state_migration.py b/tests/test_sqlite_state_migration.pyindex dc1cc5b6e..50b69b261 100644--- a/tests/test_sqlite_state_migration.py+++ b/tests/test_sqlite_state_migration.py@@ -144,6 +144,42 @@ def test_run_migrations_repairs_head_columns_before_stamping_head(tmp_path: Pathassert background_tables_ready(db_path) is True+def test_run_migrations_backfills_existing_session_policy_only_for_targeted_definitions(tmp_path: Path) -> None:+ db_path = tmp_path / "vibe.sqlite"+ engine = create_sqlite_engine(db_path)+ try:+ metadata.create_all(engine)+ finally:+ engine.dispose()++ with sqlite3.connect(db_path) as conn:+ conn.execute("update run_definitions set session_policy = null")+ conn.execute(+ """+ insert into run_definitions (+ id, definition_type, name, session_id, legacy_session_key, message, enabled, created_at, updated_at,+ metadata_json+ )+ values+ ('with-session-id', 'watch', 'with session id', 'ses123', '', 'watch', 1, '2026-05-22T00:00:00+00:00', '2026-05-22T00:00:00+00:00', '{}'),+ ('with-session-key', 'watch', 'with session key', '', 'slack::channel::C123', 'watch', 1, '2026-05-22T00:00:00+00:00', '2026-05-22T00:00:00+00:00', '{}'),+ ('without-target', 'watch', 'without target', '', '', 'watch', 1, '2026-05-22T00:00:00+00:00', '2026-05-22T00:00:00+00:00', '{}')+ """+ )+ conn.execute("create table alembic_version (version_num varchar(32) not null)")+ conn.execute("insert into alembic_version values ('20260515_0002')")+ conn.commit()++ run_migrations(db_path)++ with sqlite3.connect(db_path) as conn:+ rows = dict(conn.execute("select id, session_policy from run_definitions where id like 'with%' or id = 'without-target'"))++ assert rows["with-session-id"] == "existing"+ assert rows["with-session-key"] == "existing"+ assert rows["without-target"] is None++def test_run_migrations_does_not_stamp_partial_schema_missing_scopes(tmp_path: Path) -> None:db_path = tmp_path / "vibe.sqlite"with sqlite3.connect(db_path) as conn: