A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Remove the host opt-in flag (#11355)
Trevor Manz523e65932335
diff --git a/docs/guides/generate_with_ai/marimo_pair.md b/docs/guides/generate_with_ai/marimo_pair.mdindex 8932439018..5ba12d10d6 100644--- a/docs/guides/generate_with_ai/marimo_pair.md+++ b/docs/guides/generate_with_ai/marimo_pair.md@@ -35,17 +35,15 @@ Run `uvx marimo@latest pair --help` for the available commands.## Receive notebook messages in your agentAgent messages let you send notebook errors to a connected conversation.-This preview requires host support on the marimo server.Agent connections require a saved notebook inside the server project.Start the server with:```bash-MARIMO_ENABLE_HOST=1 uvx marimo@latest edit my_notebook.py+uvx marimo@latest edit my_notebook.py```-If the server is already running, restart it with this setting.-Then open **Connect your agent** and follow the dialog instructions.+Open **Connect your agent** and follow the dialog instructions.Supported agents have these requirements:diff --git a/marimo/_cli/pair/client.py b/marimo/_cli/pair/client.pyindex 350faff4e8..6af706ae4e 100644--- a/marimo/_cli/pair/client.py+++ b/marimo/_cli/pair/client.py@@ -697,7 +697,7 @@ def resolve_host(url: str, *, root: Path | None = None) -> HostEndpoint:except (OSError, ValueError, msgspec.DecodeError, psutil.Error):continueraise PairError(- "No live host record matches this URL. Start a local edit server with MARIMO_ENABLE_HOST=1, or restart the existing server with it."+ "No live host record matches this URL. Start a local edit server, or restart the existing server.")diff --git a/marimo/_cli/pair/commands.py b/marimo/_cli/pair/commands.pyindex 2756436014..a3bf3d640b 100644--- a/marimo/_cli/pair/commands.py+++ b/marimo/_cli/pair/commands.py@@ -86,7 +86,6 @@ class _DocsCommand(ColoredCommand):Notebook discovery uses the editor token. Pass --token-file <PATH> tonotebook list or execute without --notebook when a token is required.Host commands read their token from the private local host record.- With host support off, execution uses the editor token and stable Session.\bWorkflow:@@ -96,8 +95,7 @@ class _DocsCommand(ColoredCommand):marimo pair notebook listConnect to the notebook before waiting for work.Run marimo pair connect --help to check supported harnesses.- If your harness is supported, start the server with MARIMO_ENABLE_HOST=1,- then run (restart an existing server to enable host support):+ If your harness is supported, run:marimo pair connect --url <URL> --notebook <NOTEBOOK>Otherwise, work with the notebook using pair execute:marimo pair execute --url <URL> --session <SESSION> --code-file - <<'PY'@@ -126,7 +124,6 @@ class _DocsCommand(ColoredCommand):\bAgent messages (preview):- Start the server with MARIMO_ENABLE_HOST=1. The CLI needs no flag.Inside Codex, Claude Code, or OpenCode, run:marimo pair connect --url <URL> --notebook <NOTEBOOK>.Codex must use its shared daemon and support codex queue.diff --git a/marimo/_cli/pair/forwarder.py b/marimo/_cli/pair/forwarder.pyindex e8efb02ee5..1ce75a1397 100644--- a/marimo/_cli/pair/forwarder.py+++ b/marimo/_cli/pair/forwarder.py@@ -129,7 +129,7 @@ def start_forwarder(or process.poll() is not None):raise PairError(- "The agent message forwarder could not attach. Check the server, token and MARIMO_ENABLE_HOST=1."+ "The agent message forwarder could not attach. Check the server and token.")return recordexcept (OSError, psutil.Error, PairError):diff --git a/marimo/_config/settings.py b/marimo/_config/settings.pyindex 2711ff194d..4e6c1a2374 100644--- a/marimo/_config/settings.py+++ b/marimo/_config/settings.py@@ -15,8 +15,6 @@ class GlobalSettings:YES: bool = FalseCHECK_STATUS_UPDATE: bool = FalseTRACING: bool = is_env_true("MARIMO_TRACING")- # Temporary opt-in while the host protocol is experimental.- ENABLE_HOST: bool = is_env_true("MARIMO_ENABLE_HOST")PROFILE_DIR: str | None = NoneLOG_LEVEL: int = logging.WARNINGMANAGE_SCRIPT_METADATA: bool = is_env_true("MARIMO_MANAGE_SCRIPT_METADATA")diff --git a/marimo/_server/api/deps.py b/marimo/_server/api/deps.pyindex 80ea31d44d..ce9977f7e4 100644--- a/marimo/_server/api/deps.py+++ b/marimo/_server/api/deps.py@@ -6,7 +6,6 @@ from typing import TYPE_CHECKING, Any, castfrom marimo import _loggers as loggersfrom marimo._cli.tips import CliTipfrom marimo._config.manager import MarimoConfigManager, ScriptConfigReader-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._server.config import StarletteServerStatefrom marimo._server.session_manager import SessionManagerfrom marimo._server.tokens import SkewProtectionToken@@ -205,11 +204,6 @@ class AppState(AppStateBase):return self.session_by_stable_id(stable_session_id)- def require_host(self) -> None:- """Reject agent-aware routes when host support is disabled."""- if not GLOBAL_SETTINGS.ENABLE_HOST:- raise HTTPException(status_code=HTTPStatus.NOT_FOUND)-def session_by_stable_id(self, stable_id: str) -> Session:"""Resolve a notebook's stable session ID.diff --git a/marimo/_server/api/endpoints/pair.py b/marimo/_server/api/endpoints/pair.pyindex 6a19437653..10ecd9dfc0 100644--- a/marimo/_server/api/endpoints/pair.py+++ b/marimo/_server/api/endpoints/pair.py@@ -23,7 +23,6 @@ pair_router = APIRouter()async def messages(request: Request) -> Response:"""Send any JSON content to all agents attached to the notebook."""state = AppState(request)- state.require_host()session = state.session_by_stable_id(request.path_params["id"])try:payload = msgspec.json.decode(await request.body())@@ -55,7 +54,6 @@ class DetachRequest(msgspec.Struct):async def detach(request: Request) -> Response:"""Disconnect one attachment without stopping its notebook runtime."""state = AppState(request)- state.require_host()session = state.session_by_stable_id(request.path_params["id"])try:body = msgspec.json.decode(await request.body(), type=DetachRequest)diff --git a/marimo/_server/host/lifespan.py b/marimo/_server/host/lifespan.pyindex 70b58e27c5..af16e78293 100644--- a/marimo/_server/host/lifespan.py+++ b/marimo/_server/host/lifespan.py@@ -9,7 +9,6 @@ import secretsfrom typing import TYPE_CHECKINGfrom marimo import _loggers-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._server.api.deps import AppStateBasefrom marimo._server.api.utils import format_url_hostfrom marimo._server.host.bridge import SessionBridge@@ -30,7 +29,7 @@ LOGGER = _loggers.marimo_logger()async def host(app: Starlette) -> AsyncIterator[None]:"""Initialize the host API and discovery record in edit mode."""state = AppStateBase.from_app(app)- if not GLOBAL_SETTINGS.ENABLE_HOST or state.mode is not SessionMode.EDIT:+ if state.mode is not SessionMode.EDIT:yieldreturndiff --git a/marimo/_server/main.py b/marimo/_server/main.pyindex c3e8b99d1c..ac98876be0 100644--- a/marimo/_server/main.py+++ b/marimo/_server/main.py@@ -60,12 +60,10 @@ def create_starlette_app(skew_protection: bool = True,timeout: float | None = None,) -> Starlette:- final_middlewares: list[Middleware] = []- if GLOBAL_SETTINGS.ENABLE_HOST:- # Handle host API requests first to bypass the editor's middleware.- final_middlewares.append(- Middleware(HostApiMiddleware, base_url=base_url)- )+ # Handle host API requests first to bypass the editor's middleware.+ final_middlewares: list[Middleware] = [+ Middleware(HostApiMiddleware, base_url=base_url)+ ]if allow_origins is None:allow_origins = ("localhost", "127.0.0.1") + (diff --git a/marimo/_templates.py b/marimo/_templates.pyindex c23045f5b3..b537c35a23 100644--- a/marimo/_templates.py+++ b/marimo/_templates.py@@ -14,7 +14,6 @@ from typing import TYPE_CHECKING, Any, Literal, castfrom marimo._ast.app_config import _AppConfigfrom marimo._cli.pair.prompts import get_pair_command, load_prompt_templatesfrom marimo._config.config import MarimoConfig, PartialMarimoConfig-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._convert.common.filename import parse_titlefrom marimo._convert.converters import MarimoConvertfrom marimo._messaging.notification import ModelLifecycleNotification@@ -144,7 +143,7 @@ def _get_mount_config({"command": get_pair_command(),"templates": asdict(load_prompt_templates()),- "hostEnabled": GLOBAL_SETTINGS.ENABLE_HOST and mode == "edit",+ "hostEnabled": mode == "edit",})host_notebook = (diff --git a/protocols/host/README.md b/protocols/host/README.mdindex 5fd954f94e..4ee2520795 100644--- a/protocols/host/README.md+++ b/protocols/host/README.md@@ -14,7 +14,7 @@ The OpenAPI schema is the source of truth for the Python types in`frontend/src/core/host/protocol.ts`. The frontend generator also adds thenative `marimo` event with an `unknown` payload.-With `MARIMO_ENABLE_HOST=1`, the editor consumes host events over WebSockets+The editor consumes host events over WebSocketswhen its runtime configuration includes a `notebookId`. With`server.transport = "sse"`, it continues using the legacy `/sse` sessionstream, even when a notebook ID is available. The host's SSE endpoint servesdiff --git a/protocols/host/conformance/README.md b/protocols/host/conformance/README.mdindex 0bdb90efdd..5e1632d791 100644--- a/protocols/host/conformance/README.md+++ b/protocols/host/conformance/README.md@@ -4,7 +4,7 @@ Python tests for hosts implementing the [host protocol](../spec.md). The suiteuses HTTP and SSE and does not import marimo.Start a host in a disposable workspace (for marimo, use-`MARIMO_ENABLE_HOST=1 marimo edit`), then run this from the repository root:+`marimo edit`), then run this from the repository root:```shuv run --locked --project protocols/host/conformance \diff --git a/tests/_cli/_pair_server.py b/tests/_cli/_pair_server.pyindex f8b61c95ae..5172be7e0b 100644--- a/tests/_cli/_pair_server.py+++ b/tests/_cli/_pair_server.py@@ -2,7 +2,6 @@from __future__ import annotationsimport json-import osimport socketimport subprocessimport sys@@ -168,7 +167,6 @@ def _start_server(notebook: Path,stderr_path: Path,*,- host_enabled: bool,token: str | None,attempts: int = 3,) -> tuple[subprocess.Popen[bytes], str]:@@ -195,10 +193,6 @@ def _start_server(stdout=subprocess.DEVNULL,stderr=stderr_file,cwd=notebook.parent,- env={- **os.environ,- "MARIMO_ENABLE_HOST": "1" if host_enabled else "0",- },)url = f"http://127.0.0.1:{port}"try:@@ -214,15 +208,13 @@ def _start_server(@contextmanagerdef pair_test_server(- tmp_path: Path, *, host_enabled: bool = True, token: str | None = None+ tmp_path: Path, *, token: str | None = None) -> Generator[PairTestServer, None, None]:notebook = tmp_path / "pair-integration.py"notebook.write_text("import marimo\napp = marimo.App()\n")stderr_path = tmp_path / "marimo-stderr.log"- process, url = _start_server(- notebook, stderr_path, host_enabled=host_enabled, token=token- )+ process, url = _start_server(notebook, stderr_path, token=token)try:session_id = f"pair_{uuid.uuid4().hex[:8]}"websocket = websockets.sync.client.connect(diff --git a/tests/_cli/test_cli_pair.py b/tests/_cli/test_cli_pair.pyindex 3fa6fa5378..0ea8176954 100644--- a/tests/_cli/test_cli_pair.py+++ b/tests/_cli/test_cli_pair.py@@ -64,7 +64,6 @@ Usage: main pair [OPTIONS] COMMAND [ARGS]...Notebook discovery uses the editor token. Pass --token-file <PATH> tonotebook list or execute without --notebook when a token is required.Host commands read their token from the private local host record.- With host support off, execution uses the editor token and stable Session.Workflow:If no server is running, start one in the background:@@ -73,8 +72,7 @@ Usage: main pair [OPTIONS] COMMAND [ARGS]...marimo pair notebook listConnect to the notebook before waiting for work.Run marimo pair connect --help to check supported harnesses.- If your harness is supported, start the server with MARIMO_ENABLE_HOST=1,- then run (restart an existing server to enable host support):+ If your harness is supported, run:marimo pair connect --url <URL> --notebook <NOTEBOOK>Otherwise, work with the notebook using pair execute:marimo pair execute --url <URL> --session <SESSION> --code-file - <<'PY'@@ -101,7 +99,6 @@ Usage: main pair [OPTIONS] COMMAND [ARGS]...or when execution is unconfirmed.Agent messages (preview):- Start the server with MARIMO_ENABLE_HOST=1. The CLI needs no flag.Inside Codex, Claude Code, or OpenCode, run:marimo pair connect --url <URL> --notebook <NOTEBOOK>.Codex must use its shared daemon and support codex queue.diff --git a/tests/_cli/test_pair_integration.py b/tests/_cli/test_pair_integration.pyindex 6f7849b67f..a61e401863 100644--- a/tests/_cli/test_pair_integration.py+++ b/tests/_cli/test_pair_integration.py@@ -124,21 +124,20 @@ def editor_server() -> Generator[PairTestServer, None, None]:with pair_test_server(tmp_path_factory.mktemp("pair-editor"),- host_enabled=False,token="pair-editor-private-token",) as running:yield running@pytest.mark.parametrize("selector", ["session", "auto"])-def test_editor_execution_without_host_preserves_session_contract(+def test_authenticated_execution_preserves_session_contract(editor_server: PairTestServer,tmp_path: Path,selector: Literal["session", "auto"],) -> None:token_file = tmp_path / "token"token_file.write_text("pair-editor-private-token")- assert editor_server.notebook_id is None+ assert editor_server.notebook_id is not Noneresult = _run(editor_server,"--token-file",@@ -156,7 +155,7 @@ def test_editor_execution_without_host_preserves_session_contract("data": "<pre class='text-xs'>42</pre>",}assert payload["session"] == {"id": editor_server.stable_session_id}- assert "notebook" not in payload+ assert payload["notebook"]["id"] == editor_server.notebook_iddef test_editor_execution_requires_editor_token(diff --git a/tests/_server/api/endpoints/test_pair_endpoints.py b/tests/_server/api/endpoints/test_pair_endpoints.pyindex ce006fc29a..1301f37ed1 100644--- a/tests/_server/api/endpoints/test_pair_endpoints.py+++ b/tests/_server/api/endpoints/test_pair_endpoints.py@@ -9,7 +9,6 @@ import pytestfrom marimo._ast.app import App, InternalAppfrom marimo._config.manager import get_default_config_manager-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._core import protocolfrom marimo._messaging.messages import AGENT_MESSAGE_TYPEfrom marimo._server.host.bridge import SessionBridge@@ -35,11 +34,6 @@ if TYPE_CHECKING:from marimo._core.notebook import Notebook[email protected](autouse=True)-def enable_host(monkeypatch: pytest.MonkeyPatch) -> None:- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", True)--@pytest.fixtureasync def target(client: TestClient, tmp_path: Path@@ -201,25 +195,6 @@ def test_invalid_message_json()[email protected]("operation", ["messages", "attachments/detach"])-def test_host_gate(- client: TestClient,- target: tuple[SessionImpl, Notebook],- monkeypatch: pytest.MonkeyPatch,- operation: str,-) -> None:- session, _ = target- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", False)- assert (- client.post(- path(session, operation),- json={},- headers=token_header("fake-token"),- ).status_code- == 404- )--@pytest.mark.parametrize("operation", ["messages", "attachments/detach"])def test_missing_session(client: TestClient, operation: str) -> None:assert (diff --git a/tests/_server/host/conftest.py b/tests/_server/host/conftest.pyindex 946498d4d3..5efe780541 100644--- a/tests/_server/host/conftest.py+++ b/tests/_server/host/conftest.py@@ -9,7 +9,6 @@ from unittest.mock import MagicMockimport pytest-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._core import backend as befrom marimo._messaging.notebook import NotebookDocumentfrom marimo._messaging.notification import NotificationMessage@@ -21,11 +20,6 @@ from marimo._session.types import KernelStatefrom marimo._types.ids import ConsumerId-def enable_host(monkeypatch: pytest.MonkeyPatch) -> None:- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", True)--class FakeSession:"""A session fake with a real scratchpad lock and event bus."""diff --git a/tests/_server/host/test_host_api.py b/tests/_server/host/test_host_api.pyindex 384d292819..4392660082 100644--- a/tests/_server/host/test_host_api.py+++ b/tests/_server/host/test_host_api.py@@ -59,7 +59,6 @@ if TYPE_CHECKING:TOKEN = "record-token"AUTH = {"Authorization": f"Bearer {TOKEN}"}-pytestmark = pytest.mark.usefixtures("enable_host")async def analyzed(notebook: Notebook) -> protocol.Analysis:diff --git a/tests/_server/host/test_host_execution.py b/tests/_server/host/test_host_execution.pyindex 67186c913a..1160412cd3 100644--- a/tests/_server/host/test_host_execution.py+++ b/tests/_server/host/test_host_execution.py@@ -32,7 +32,6 @@ if TYPE_CHECKING:from tests._server.host.drive import ResponseAUTH = {"Authorization": "Bearer execution-test"}-pytestmark = pytest.mark.usefixtures("enable_host")def key(value: str) -> dict[str, str]:diff --git a/tests/_server/host/test_host_record.py b/tests/_server/host/test_host_record.pyindex 852079d30b..3680c94e1f 100644--- a/tests/_server/host/test_host_record.py+++ b/tests/_server/host/test_host_record.py@@ -13,7 +13,6 @@ import msgspecimport pytestimport uvicorn-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._core import backend as be, protocolfrom marimo._server.host import HOST_API_PATH, record as record_modulefrom marimo._server.host.lifespan import host as host_lifespan@@ -37,8 +36,6 @@ from tests._server.mocks import (if TYPE_CHECKING:from pathlib import Path-pytestmark = pytest.mark.usefixtures("enable_host")-@pytest.mark.parametrize(("host", "loopback"),@@ -86,22 +83,16 @@ async def test_an_unreachable_bind_writes_no_record(assert app.state.host_context is not None- ("enabled", "mode"), [(False, SessionMode.EDIT), (True, SessionMode.RUN)]-)-async def test_inactive_host_writes_no_record_and_serves_no_api(+async def test_run_mode_writes_no_record_and_serves_no_host_api(tmp_path: Path,monkeypatch: pytest.MonkeyPatch,- enabled: bool,- mode: SessionMode,) -> None:- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", enabled)monkeypatch.setattr(record_module, "marimo_state_dir", lambda: tmp_path)app = create_starlette_app(base_url="", enable_auth=False, lifespan=Lifespans([host_lifespan]))get_starlette_server_state_init(- session_manager=get_mock_session_manager(mode=mode)+ session_manager=get_mock_session_manager(mode=SessionMode.RUN)).apply(app.state)app.state.server = uvicorn.Server(uvicorn.Config(app, host="127.0.0.1", port=1234)diff --git a/tests/_server/templates/test_templates_api.py b/tests/_server/templates/test_templates_api.pyindex 059f2bd07f..7b4c12d0b2 100644--- a/tests/_server/templates/test_templates_api.py+++ b/tests/_server/templates/test_templates_api.py@@ -7,7 +7,6 @@ from dataclasses import asdictimport pytestfrom marimo._cli.pair.prompts import load_prompt_templates-from marimo._config.settings import GLOBAL_SETTINGSfrom marimo._schemas.session import (VERSION,Cell,@@ -22,18 +21,15 @@ from marimo._server.templates.api import (from tests._server.templates.utils import parse_mount_config[email protected]("enabled", [True, False])@pytest.mark.parametrize(("editable", "command"),[(True, "uv run marimo"), (False, "uvx marimo@latest")],)def test_pair_cli_config_is_unconditional(monkeypatch: pytest.MonkeyPatch,- enabled: bool,editable: bool,command: str,) -> None:- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", enabled)monkeypatch.setattr("marimo._cli.pair.prompts.is_editable", lambda _: editable)@@ -43,14 +39,11 @@ def test_pair_cli_config_is_unconditional(assert parse_mount_config(html)["pairConfig"] == {"command": command,"templates": asdict(load_prompt_templates()),- "hostEnabled": enabled,+ "hostEnabled": True,}-def test_read_mode_disables_agent_aware_ui(- monkeypatch: pytest.MonkeyPatch,-) -> None:- monkeypatch.setattr(GLOBAL_SETTINGS, "ENABLE_HOST", True)+def test_read_mode_disables_agent_aware_ui() -> None:html = render_notebook(code="import marimo\napp = marimo.App()", mode="read")