diff --git a/adapters/python/openclaw/README.md b/adapters/python/openclaw/README.md index 01d13b72d..6b223d3ac 100644 --- a/adapters/python/openclaw/README.md +++ b/adapters/python/openclaw/README.md @@ -55,7 +55,7 @@ Before migration, copy every legacy session directory while the Gateway is stopp Run `openclaw doctor --fix` with the 2026.9.34 executable and the same path settings. The command imports legacy `sessions.json` files and JSONL session data into each agent's SQLite database. Restart the Gateway after the command succeeds. Keep the verified backup for rollback. -Managed runtimes and NeMo Fabric-owned services use temporary state directories by default, so each new Gateway starts with fresh state. With `runtime.keep_state`, the Gateway's `OPENCLAW_STATE_DIR` is the agent's state folder, `/.fabric/state/nvidia.fabric.openclaw/`, for every runtime of the agent; see [Keep OpenClaw State Across Runtimes](../../../docs/integrations/harness/openclaw.mdx#keep-openclaw-state-across-runtimes). +Managed runtimes and NeMo Fabric-owned services use temporary state directories, so each new Gateway starts with fresh state. ## Configuration @@ -70,10 +70,8 @@ The adapter maps these fields into a generated `openclaw.json` before starting the Gateway. A non-empty `tools.enabled` list maps to `tools.allow`, an empty list maps to a wildcard `tools.deny` policy, and `tools.blocked` maps to `tools.deny`. It uses a generated one-time token, loopback binding, and an -isolated temporary OpenClaw state directory, or the agent's state folder with -`runtime.keep_state`. The Gateway is stopped and its temporary configuration is -removed when the NeMo Fabric runtime stops; a kept state folder is never -removed. +isolated temporary OpenClaw state directory. The Gateway is stopped and its +temporary configuration is removed when the NeMo Fabric runtime stops. Each `skills.paths` entry is a skill or a folder of skills, as [Load Skills from Folders](../../../docs/integrations/harness/skills.mdx) diff --git a/adapters/python/openclaw/openclaw.fabric-adapter.json b/adapters/python/openclaw/openclaw.fabric-adapter.json index 1aa9df645..f77440d86 100644 --- a/adapters/python/openclaw/openclaw.fabric-adapter.json +++ b/adapters/python/openclaw/openclaw.fabric-adapter.json @@ -97,7 +97,7 @@ "port" ], "additionalProperties": false, - "description": "OpenClaw's Control UI. After the Gateway starts, the adapter writes its sign-in token to interfaces/dashboard.token in /.fabric/openclaw/runtimes/, or in the agent's state folder with runtime.keep_state." + "description": "OpenClaw's Control UI. After the Gateway starts, the adapter writes its sign-in token to /.fabric/openclaw/runtimes//interfaces/dashboard.token." }, "terminal": { "type": "object", @@ -208,7 +208,6 @@ "models.top_p", "models.max_tokens", "instructions.system", - "runtime.keep_state", "tools.enabled", "tools.blocked", "mcp", diff --git a/adapters/python/openclaw/src/nemo_fabric_adapters/openclaw/adapter.py b/adapters/python/openclaw/src/nemo_fabric_adapters/openclaw/adapter.py index 2b85ed500..9da15ba2d 100644 --- a/adapters/python/openclaw/src/nemo_fabric_adapters/openclaw/adapter.py +++ b/adapters/python/openclaw/src/nemo_fabric_adapters/openclaw/adapter.py @@ -190,10 +190,6 @@ def _dashboard_port(settings: dict[str, Any]) -> int | None: def _dashboard_token_path(context: contract.RuntimeContext, base_dir: Path) -> Path: - # With runtime.keep_state, interfaces live in the agent's state folder, - # where every runtime of the agent finds them, as Hermes's do. - if context.state_dir: - return Path(context.state_dir) / "interfaces" / "dashboard.token" root = context.artifacts.root artifact_root = (base_dir / str(root)).resolve() if root else base_dir / "artifacts" return ( @@ -1204,31 +1200,7 @@ async def start(self, payload: dict[str, Any]) -> dict[str, Any] | None: await self._connect_service_runtime(config, context, settings, service) return None if service is not None and service.get("operation") == "attach": - if context.state_dir: - raise lifecycle.LifecycleError( - "openclaw_keep_state_requires_managed_gateway", - "OpenClaw keeps state only for a Gateway that NeMo Fabric " - "starts; an attached Gateway keeps its state where its " - "deployment puts it", - metadata={"field": "runtime.keep_state"}, - ) return await self._attach_service(config, context, settings, service) - if context.state_dir: - # A runtime that ended without stop can leave its dashboard token - # and interface files in the kept state, for a Gateway that no - # longer runs. - interface_directory = _dashboard_token_path(context, base_dir).parent - try: - (interface_directory / "dashboard.token").unlink(missing_ok=True) - except OSError: - removed = False - else: - removed = native_interfaces.remove(interface_directory) - if not removed: - raise lifecycle.LifecycleError( - "openclaw_interface_cleanup_failed", - "OpenClaw interface files could not be removed", - ) child_env = common_utils.virtualenv_subprocess_env() child_env.update(context.environment.env) if model.api_key_env is not None and not child_env.get(model.api_key_env): @@ -1291,19 +1263,9 @@ def startup_remaining() -> float: token = secrets.token_urlsafe(48) token_env = "OPENCLAW_GATEWAY_TOKEN" - # The generated configuration is this runtime's alone, so it stays in a - # temporary folder that stop removes, with or without kept state. temp_dir = tempfile.TemporaryDirectory(prefix="nemo-fabric-openclaw-") - if context.state_dir: - # With runtime.keep_state, OpenClaw's native state, such as its - # sessions and the skills the agent writes, is the agent's state - # folder. Fabric locks that folder for one runtime at a time and - # never removes it; neither does the adapter. - state_dir = Path(context.state_dir) - state_dir.mkdir(mode=0o700, parents=True, exist_ok=True) - else: - state_dir = Path(temp_dir.name) / "state" - state_dir.mkdir(mode=0o700) + state_dir = Path(temp_dir.name) / "state" + state_dir.mkdir(mode=0o700) config_path = Path(temp_dir.name) / "openclaw.json" generated = _openclaw_config( config, diff --git a/docs/integrations/harness/openclaw/openclaw.mdx b/docs/integrations/harness/openclaw/openclaw.mdx index 6f01dad63..9b3a8a1e8 100644 --- a/docs/integrations/harness/openclaw/openclaw.mdx +++ b/docs/integrations/harness/openclaw/openclaw.mdx @@ -65,7 +65,7 @@ Before migration, copy every legacy session directory while the Gateway is stopp Run `openclaw doctor --fix` with the 2026.9.34 executable and the same path settings. The command imports legacy `sessions.json` files and JSONL session data into each agent's SQLite database. Restart the Gateway after the command succeeds. Keep the verified backup for rollback. -Managed runtimes and NeMo Fabric-owned services use temporary state directories by default, so each new Gateway starts with fresh state. To keep OpenClaw's state across runtimes, set `runtime.keep_state` as [Keep OpenClaw State Across Runtimes](#keep-openclaw-state-across-runtimes) describes. +Managed runtimes and NeMo Fabric-owned services use temporary state directories, so each new Gateway starts with fresh state. ## Configure the Adapter @@ -149,65 +149,7 @@ settings = { The dashboard selects the existing Gateway's base port. Terminal has no port; it discovers that same Gateway, or uses the existing allocator when dashboard is absent. The dashboard port conflicts with `port_range`. Both clients can attach in parallel with SDK and native HTTP clients; use distinct sessions to keep conversations separate. -After readiness, the adapter publishes private connection material under `/.fabric/openclaw/runtimes//interfaces/`, or under `interfaces/` in the agent's state folder with `runtime.keep_state`. `gateway.json` contains endpoints, selected agent, executable, workspace, and a credential-file reference. The token is in `dashboard.token` when the dashboard is enabled, otherwise `gateway.token`. Terminal adds an executable `terminal` and `terminal.running` marker. Stop removes the marker first and revokes discovery and credentials before stopping the Gateway. An abrupt host kill can leave files; attachment also checks authenticated Gateway availability. - -## Keep OpenClaw State Across Runtimes - -By default, each Gateway that the adapter starts uses a temporary -`OPENCLAW_STATE_DIR` that `stop` removes, so the sessions, memory, and skills -that the agent writes there are lost when the runtime stops. Set `keep_state` -in the config's `runtime` mapping to keep that folder: - -```python -from nemo_fabric import FabricConfig - -config = FabricConfig.from_mapping( - { - "metadata": {"name": "assistant"}, - "harness": {"adapter_id": "nvidia.fabric.openclaw"}, - "models": {"default": {"provider": "nvidia", "model": ""}}, - "runtime": {"artifacts": "/data/artifacts", "keep_state": True}, - } -) -``` - -With `runtime.keep_state`, the Gateway's `OPENCLAW_STATE_DIR` is the agent's -state folder, `/.fabric/state/nvidia.fabric.openclaw/`, -for every runtime of the agent and for a NeMo Fabric-owned service: - -- Skills that the agent writes through OpenClaw's Skill Workshop stay at the - path where OpenClaw saved them, - `agents//agent/workshop-skills//SKILL.md` in that folder, - and the next Gateway discovers them there. The adapter doesn't copy, move, or - recreate them. -- The generated `openclaw.json` and the Gateway token remain specific to one - runtime: the adapter writes the configuration to a temporary folder at each - start and removes it at stop. The native interface files, including the - dashboard token, are written to `interfaces/` in the state folder, removed - by `stop`, and removed at the next start if an earlier runtime ended without - `stop`. A removal failure stops startup with - `openclaw_interface_cleanup_failed` before the Gateway starts. -- `stop` and a failed start never remove the state folder or its contents. -- NeMo Fabric lets one runtime at a time use the folder, as - [Keep Agent State Across Runtimes](../../../sdk/python.mdx#keep-agent-state-across-runtimes) - describes. A second runtime of the agent fails to start while the first runs. -- An attached caller-owned Gateway keeps its state where its deployment puts - it, so attaching a service with `runtime.keep_state` fails with - `openclaw_keep_state_requires_managed_gateway`. - -Kept state lasts as long as the artifact root does. When the runtime runs in a -container or sandbox that is replaced, put the artifact root on durable storage, -such as a Kubernetes persistent volume. The folder can hold sessions, -credentials, and sign-ins, so protect it like a home directory. To discard it, -stop every runtime and service of the agent, then remove the folder. - -Keeping files doesn't by itself keep a plugin that the agent installed enabled -and usable: the adapter generates a read-only `openclaw.json` at each start, and -plugin use after a restart is not yet qualified. - -Keeping state doesn't continue an earlier conversation: each invocation still -uses the NeMo Fabric runtime ID as its OpenClaw session key, so a new runtime -starts a new session, and earlier sessions stay in the state folder. +After readiness, the adapter publishes private connection material under `/.fabric/openclaw/runtimes//interfaces/`. `gateway.json` contains endpoints, selected agent, executable, workspace, and a credential-file reference. The token is in `dashboard.token` when the dashboard is enabled, otherwise `gateway.token`. Terminal adds an executable `terminal` and `terminal.running` marker. Stop removes the marker first and revokes discovery and credentials before stopping the Gateway. An abrupt host kill can leave files; attachment also checks authenticated Gateway availability. ## Testing and Limitations diff --git a/docs/sdk/python.mdx b/docs/sdk/python.mdx index 2fb109bf4..94610cd22 100644 --- a/docs/sdk/python.mdx +++ b/docs/sdk/python.mdx @@ -906,7 +906,7 @@ The operating system releases the lock after all copies of the lock have closed: - **Windows:** Adapter hosts do not inherit the lock. Only the NeMo Fabric process holds the lock, so the folder becomes available if that process exits while an adapter host is still running. - **Detached processes:** A native process can continue accessing the state folder after all lock descriptors close. A replacement runtime can then acquire the lock while the detached process still writes to the folder. -Planning fails without an artifact directory or for an adapter that doesn't declare `runtime.keep_state`. The Hermes Agent and OpenClaw adapters declare `runtime.keep_state`. +Planning fails without an artifact directory or for an adapter that doesn't declare `runtime.keep_state`. The Hermes Agent adapter declares `runtime.keep_state`. ## Runtime Resource Snapshots diff --git a/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json b/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json index a52277fee..a3c67923e 100644 --- a/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json +++ b/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json @@ -2047,7 +2047,6 @@ "models.top_p", "models.max_tokens", "instructions.system", - "runtime.keep_state", "tools.enabled", "tools.blocked", "mcp", @@ -2234,7 +2233,7 @@ "properties": { "dashboard": { "additionalProperties": false, - "description": "OpenClaw's Control UI. After the Gateway starts, the adapter writes its sign-in token to interfaces/dashboard.token in /.fabric/openclaw/runtimes/, or in the agent's state folder with runtime.keep_state.", + "description": "OpenClaw's Control UI. After the Gateway starts, the adapter writes its sign-in token to /.fabric/openclaw/runtimes//interfaces/dashboard.token.", "properties": { "enabled": { "default": true, @@ -2330,7 +2329,7 @@ "name": "nemo-fabric-adapters-openclaw", "version": "0.7.0" }, - "sha256": "fbcead9c7db27d3c41ab93350b90c3b815570a7e51fb09fb6f498bff458af970", + "sha256": "dbfb74e0d2a2ba4db50bdc0d93140c0de3abc07d90f6551b9dd1f28458b9cc59", "source": "adapters/python/openclaw/openclaw.fabric-adapter.json" }, "nvidia.fabric.opencode": { diff --git a/tests/_utils/mock_openclaw.py b/tests/_utils/mock_openclaw.py index 6da383555..fa4fdf0ee 100755 --- a/tests/_utils/mock_openclaw.py +++ b/tests/_utils/mock_openclaw.py @@ -4,57 +4,12 @@ """Mock OpenClaw CLI and Gateway used by adapter tests.""" -import hashlib import json import os import signal import sys import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from pathlib import Path - - -def workshop_skills() -> Path: - """Where the agent saves the skills it writes, inside OpenClaw's state.""" - return ( - Path(os.environ["OPENCLAW_STATE_DIR"]) - / "agents" - / "default" - / "agent" - / "workshop-skills" - ) - - -def skill_reply(request: dict) -> str | None: - """Write or use a skill the way the agent does, for retention tests. - - `author-skill ` saves a new skill in OpenClaw's state. - `use-skill ` discovers it there, reads it, and replies with - its path, its hash, and an output that only this request can produce. - """ - messages = [m for m in request.get("messages", []) if m.get("role") == "user"] - words = str(messages[-1].get("content", "")).split() if messages else [] - if words[:1] == ["author-skill"] and len(words) == 2: - skill = workshop_skills() / words[1] / "SKILL.md" - skill.parent.mkdir(parents=True, exist_ok=True) - skill.write_text( - f"---\nname: {words[1]}\ndescription: Echo a nonce.\n---\n\n" - "Reply with the skill name and the nonce.\n", - encoding="utf-8", - ) - elif words[:1] != ["use-skill"] or len(words) != 3: - return None - found = sorted(workshop_skills().glob("*/SKILL.md")) - skill = next((path for path in found if path.parent.name == words[1]), None) - if skill is None: - return "SKILL_MISSING" - return json.dumps( - { - "path": str(skill), - "sha256": hashlib.sha256(skill.read_bytes()).hexdigest(), - "output": f"{words[1]}:{words[2]}" if words[0] == "use-skill" else None, - } - ) args = sys.argv[1:] @@ -78,9 +33,6 @@ def skill_reply(request: dict) -> str | None: if readonly_path := os.environ.get("FAKE_OPENCLAW_CONFIG_READONLY"): with open(readonly_path, "w", encoding="utf-8") as stream: stream.write(os.environ.get("OPENCLAW_CONFIG_READONLY", "")) -if state_path := os.environ.get("FAKE_OPENCLAW_STATE_CAPTURE"): - with open(state_path, "w", encoding="utf-8") as stream: - stream.write(os.environ["OPENCLAW_STATE_DIR"]) if pid_path := os.environ.get("FAKE_OPENCLAW_PID"): with open(pid_path, "w", encoding="utf-8") as stream: stream.write(str(os.getpid())) @@ -205,9 +157,7 @@ def do_POST(self): "choices": [ { "index": 0, - "delta": { - "content": skill_reply(request) or "OpenClaw response" - }, + "delta": {"content": "OpenClaw response"}, "finish_reason": None, } ], diff --git a/tests/adapters/test_openclaw.py b/tests/adapters/test_openclaw.py index 07f298dd1..96a1cc935 100644 --- a/tests/adapters/test_openclaw.py +++ b/tests/adapters/test_openclaw.py @@ -7,7 +7,6 @@ import asyncio import ctypes -import hashlib import json import os import shutil @@ -38,7 +37,6 @@ def _context( workspace: Path, runtime_id: str = "openclaw-runtime", deadline_millis: int | None = None, - state_dir: Path | None = None, ) -> RuntimeContext: payload = { "runtime_id": runtime_id, @@ -56,8 +54,6 @@ def _context( } if deadline_millis is not None: payload["deadline_millis"] = deadline_millis - if state_dir is not None: - payload["state_dir"] = str(state_dir) return RuntimeContext.from_mapping(payload) @@ -2318,230 +2314,6 @@ async def test_openclaw_fabric_service_supports_multiple_runtimes( assert (tmp_path / "stopped.txt").read_text(encoding="utf-8") == "stopped" -_MOCK_GATEWAY = pytest.mark.skipif( - sys.platform in {"darwin", "win32"}, - reason="Starts the mock Gateway, which CI runs only on Linux", -) -_RUNS_MOCK_SCRIPT = pytest.mark.skipif( - sys.platform == "win32", reason="Runs the mock openclaw script directly" -) -_AUTHORED_SKILL = Path("agents/default/agent/workshop-skills/fabric-kept/SKILL.md") - - -def _agent_config(command: Path, *, keep_state: bool) -> FabricConfig: - return FabricConfig.from_mapping( - { - "metadata": {"name": "openclaw-skills"}, - "harness": { - "adapter_id": "nvidia.fabric.openclaw", - "resolution": "preinstalled", - "settings": {"openclaw_command": str(command)}, - }, - "models": { - "default": { - "provider": "test", - "model": "fabric-echo", - "base_url": "https://models.example.test/v1", - } - }, - "runtime": {"artifacts": "artifacts", "keep_state": keep_state}, - "environment": {"provider": "local", "workspace": "."}, - } - ) - - -async def _ask(runtime, prompt: str) -> str: - result = await runtime.invoke(input=prompt) - assert result.status == "succeeded", result - return result.output["response"] - - -def _agent_state(tmp_path: Path) -> Path: - return tmp_path / "artifacts/.fabric/state/nvidia.fabric.openclaw/openclaw-skills" - - -@_MOCK_GATEWAY -async def test_openclaw_keep_state_keeps_an_authored_skill_for_the_next_runtime( - mock_openclaw: Path, tmp_path: Path -): - """A skill the agent wrote stays where it saved it and works after a restart.""" - os.environ["FAKE_OPENCLAW_CAPTURE"] = str(tmp_path / "config.json") - os.environ["FAKE_OPENCLAW_REQUEST"] = str(tmp_path / "request.json") - config = _agent_config(mock_openclaw, keep_state=True) - fabric = Fabric() - - first = await fabric.start_runtime(config, base_dir=tmp_path) - try: - authored = json.loads(await _ask(first, "author-skill fabric-kept")) - # Fabric lets one runtime at a time use the agent's state. - with pytest.raises(FabricRuntimeError, match="in use by another runtime"): - await fabric.start_runtime(config, base_dir=tmp_path) - finally: - await first.stop() - - skill = Path(authored["path"]) - assert skill.resolve() == (_agent_state(tmp_path) / _AUTHORED_SKILL).resolve() - assert hashlib.sha256(skill.read_bytes()).hexdigest() == authored["sha256"] - - second = await fabric.start_runtime(config, base_dir=tmp_path) - try: - used = json.loads(await _ask(second, "use-skill fabric-kept second-run")) - finally: - await second.stop() - - assert used == { - "path": authored["path"], - "sha256": authored["sha256"], - "output": "fabric-kept:second-run", - } - assert [path.resolve() for path in tmp_path.rglob("SKILL.md")] == [skill.resolve()] - - -@_MOCK_GATEWAY -async def test_openclaw_without_keep_state_removes_an_authored_skill_at_stop( - mock_openclaw: Path, tmp_path: Path -): - os.environ["FAKE_OPENCLAW_CAPTURE"] = str(tmp_path / "config.json") - os.environ["FAKE_OPENCLAW_REQUEST"] = str(tmp_path / "request.json") - config = _agent_config(mock_openclaw, keep_state=False) - fabric = Fabric() - - first = await fabric.start_runtime(config, base_dir=tmp_path) - try: - authored = json.loads(await _ask(first, "author-skill fabric-kept")) - finally: - await first.stop() - second = await fabric.start_runtime(config, base_dir=tmp_path) - try: - reply = await _ask(second, "use-skill fabric-kept second-run") - finally: - await second.stop() - - assert not Path(authored["path"]).is_relative_to(tmp_path) - assert not Path(authored["path"]).exists() - assert reply == "SKILL_MISSING" - assert not (tmp_path / "artifacts/.fabric/state").exists() - - -@pytest.mark.parametrize( - "failure", - [ - pytest.param("config_validate", marks=_RUNS_MOCK_SCRIPT), - pytest.param("after_gateway_start", marks=_MOCK_GATEWAY), - ], -) -async def test_openclaw_failed_start_keeps_the_agents_state( - mock_openclaw: Path, - tmp_path: Path, - monkeypatch: pytest.MonkeyPatch, - failure: str, -): - state_dir = _agent_state(tmp_path) - skill = state_dir / _AUTHORED_SKILL - skill.parent.mkdir(parents=True) - skill.write_text("---\nname: fabric-kept\n---\n", encoding="utf-8") - stale_token = state_dir / "interfaces" / "dashboard.token" - stale_token.parent.mkdir() - stale_token.write_text("stale", encoding="utf-8") - # A runtime that ended without stop can also leave the native interface - # files that point clients at its Gateway. - stale_interfaces = [stale_token] + [ - stale_token.with_name(name) for name in adapter.native_interfaces.FILES - ] - for path in stale_interfaces[1:]: - path.write_text("stale", encoding="utf-8") - stale_client_state = stale_token.with_name("client-state") - stale_client_state.mkdir() - before = skill.read_bytes() - runtime = adapter.OpenClawRuntime() - generated: list[Path] = [] - gateway_state = tmp_path / "gateway-state.txt" - monkeypatch.setenv("FAKE_OPENCLAW_STATE_CAPTURE", str(gateway_state)) - if failure == "config_validate": - # The mock fails validation when it can't record the configuration. - monkeypatch.setenv( - "FAKE_OPENCLAW_CAPTURE", str(tmp_path / "missing" / "c.json") - ) - real_command_output = adapter._command_output - - async def record_generated(command, *args, **kwargs): - if args[:1] == ("config",) and runtime._temp_dir is not None: - generated.append(Path(runtime._temp_dir.name)) - return await real_command_output(command, *args, **kwargs) - - monkeypatch.setattr(adapter, "_command_output", record_generated) - expected = adapter.lifecycle.LifecycleError - else: - monkeypatch.setenv("FAKE_OPENCLAW_CAPTURE", str(tmp_path / "config.json")) - - # Start reads the HTTP read timeout only after the Gateway is ready. - def fail_after_gateway_start(_settings): - assert runtime._temp_dir is not None - generated.append(Path(runtime._temp_dir.name)) - raise RuntimeError("start failed after the Gateway started") - - monkeypatch.setattr(adapter, "_read_timeout", fail_after_gateway_start) - expected = RuntimeError - - with pytest.raises(expected): - await runtime.start( - { - "config": _config(mock_openclaw), - "runtime_context": _context(tmp_path, state_dir=state_dir).to_mapping(), - "base_dir": str(tmp_path), - } - ) - - assert skill.read_bytes() == before - assert len(generated) == 1 and not generated[0].exists() - assert not generated[0].is_relative_to(state_dir) - assert [path for path in stale_interfaces if path.exists()] == [] - assert not stale_client_state.exists() - assert runtime._process is None and runtime._temp_dir is None - if failure == "after_gateway_start": - assert gateway_state.read_text(encoding="utf-8") == str(state_dir) - - -async def test_openclaw_attach_refuses_kept_state(tmp_path: Path): - """A caller-owned Gateway keeps its state where its deployment puts it.""" - runtime = adapter.OpenClawRuntime() - config = AgentConfig.from_mapping( - {"models": {"default": {"provider": "test", "model": "fabric-echo"}}} - ) - - with pytest.raises(adapter.lifecycle.LifecycleError) as caught: - await runtime.start( - { - "config": config, - "runtime_context": _context( - tmp_path, state_dir=_agent_state(tmp_path) - ).to_mapping(), - "base_dir": str(tmp_path), - "service": { - "operation": "attach", - "connection_path": str(tmp_path / "connection.json"), - }, - } - ) - - assert caught.value.code == "openclaw_keep_state_requires_managed_gateway" - assert caught.value.metadata == {"field": "runtime.keep_state"} - assert not (tmp_path / "connection.json").exists() - - -def test_openclaw_dashboard_token_is_in_kept_state(tmp_path: Path): - """Consumers find a kept agent's interfaces in its state folder.""" - state_dir = _agent_state(tmp_path) - - kept = adapter._dashboard_token_path( - _context(tmp_path, state_dir=state_dir), tmp_path - ) - ephemeral = adapter._dashboard_token_path(_context(tmp_path), tmp_path) - - assert kept == state_dir / "interfaces" / "dashboard.token" - assert ephemeral == _dashboard_token(tmp_path) - - @pytest.mark.parametrize( ("authentication", "capability"), [ @@ -2616,7 +2388,6 @@ def test_openclaw_descriptor_and_module_entrypoint(repo_root: Path): assert "channel_config" in descriptor["settings_schema"]["properties"] assert "tools.enabled" in descriptor["config"]["accepts"] assert "tools.blocked" in descriptor["config"]["accepts"] - assert "runtime.keep_state" in descriptor["config"]["accepts"] assert "mcp.auth.oauth2" not in descriptor["config"]["accepts"] assert "mcp.auth.service_account" not in descriptor["config"]["accepts"] assert descriptor["capabilities"]["streaming"] is False