Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(mobile): document isolated runtime validation boundaries
trohitg6c72083c9ace
diff --git a/docs/mobile-workspace.md b/docs/mobile-workspace.mdindex 0e7c7602..8ce9c06b 100644--- a/docs/mobile-workspace.md+++ b/docs/mobile-workspace.md@@ -133,6 +133,8 @@ Minitap's [platform](https://www.minitap.ai/platform#slack-cli-mcp) and [miniTes## Validation and limitations+Run backend validation with a boolean `DEBUG` environment value (for example, `$env:DEBUG='false'` in PowerShell). Values such as `release` fail settings validation in subprocess tests. Source-boundary checks exclude installed runtime data in `.opencompany` and legacy `.machina`; the mobile engine runs in its own dependency environment. The Android tool intentionally receives canvas edges to resolve its connected model, and the device driver's JSON wire replies are protocol output rather than application logs.+Automated tests exercise fencing, successful-operation deduplication, cancellation while draining, takeover and resume with fake subprocesses, queued cancellation, source-patch compatibility, and Python syntax compilation of the patched upstream package. Additional tests use the actual loopback HTTP broker with a fake driver, reject unsafe archives and checksum mismatches, and verify that SDK tools run through Java arguments without a command shell. Patch tests require `.tmp/mobile-use-upstream` or `MOBILE_USE_UPSTREAM_SOURCE` pointing to the pinned checkout; they skip when that fixture is absent.An earlier local smoke test executed `worker.main` profile construction, SDK initialization, a fake task, and cleanup using the actual pinned dependency environment in `.tmp/engine-smoke` and a fake controller. It made no model request and connected to no emulator.diff --git a/server/nodes/mobile/_node.py b/server/nodes/mobile/_node.pyindex 51cb45a5..11160707 100644--- a/server/nodes/mobile/_node.py+++ b/server/nodes/mobile/_node.py@@ -127,6 +127,7 @@ class MobileUseAgent(ActionNode):ui_hints = {"workspace": {"kind": "mobile"}, "width": 300, "height": 200}task_queue = TaskQueue.ANDROIDretry_policy = RetryPolicy(maximum_attempts=1)+ # Allow shared-phone queueing and manual-control waits before the bounded task.start_to_close_timeout = timedelta(hours=3)Params = MobileParamsOutput = MobileOutputdiff --git a/server/nodes/mobile/_tool.py b/server/nodes/mobile/_tool.pyindex 90fdeb7f..a22a6db3 100644--- a/server/nodes/mobile/_tool.py+++ b/server/nodes/mobile/_tool.py@@ -33,6 +33,7 @@ class AndroidTool(ToolNode):annotations = {"destructive": True, "readonly": False, "open_world": True}task_queue = MobileUseAgent.task_queueretry_policy = MobileUseAgent.retry_policy+ # Share the mobile agent's allowance for queueing and manual-control waits.start_to_close_timeout = MobileUseAgent.start_to_close_timeoutParams = MobileParamsToolInput = AndroidTaskInputdiff --git a/server/nodes/mobile/runtime/worker.py b/server/nodes/mobile/runtime/worker.pyindex 99e62aa1..5864837a 100644--- a/server/nodes/mobile/runtime/worker.py+++ b/server/nodes/mobile/runtime/worker.py@@ -137,6 +137,7 @@ async def main(config: dict) -> None:from minitap.mobile_use.sdk.agent import Agentfrom minitap.mobile_use.sdk.builders.agent_config_builder import AgentConfigBuilderfrom minitap.mobile_use.sdk.types.task import AgentProfile, TaskRequest+ # Only this isolated engine process uses LangChain; the server does not.from langchain_core.callbacks import BaseCallbackHandlerclass Progress(BaseCallbackHandler):diff --git a/server/services/temporal/agent_workflow.py b/server/services/temporal/agent_workflow.pyindex 18ed8bcd..f6c30f66 100644--- a/server/services/temporal/agent_workflow.py+++ b/server/services/temporal/agent_workflow.py@@ -1712,9 +1712,9 @@ class AgentWorkflow:**(tool_info.get("parameters") or {}),**call_args,}- # Canvas-aware tools (currently only agentBuilder, which- # walks edges to resolve its calling agent + mutates- # the canvas) opt in via the BaseNode.needs_canvas+ # Canvas-aware tools (agentBuilder/taskManager for caller+ # resolution and Android for its connected model) opt in+ # via the BaseNode.needs_canvas# ClassVar. Default tools execute against their own# params alone and don't see the parent canvas.plugin_cls = get_node_class(tool_info["node_type"])diff --git a/server/tests/llm/test_langchain_removed.py b/server/tests/llm/test_langchain_removed.pyindex 3cbc4243..68a66a5d 100644--- a/server/tests/llm/test_langchain_removed.py+++ b/server/tests/llm/test_langchain_removed.py@@ -2,8 +2,9 @@This file replaces ``test_legacy_langchain_boundary.py``, which allowedLangChain inside a named set of pre-cutover compatibility scopes. Those scopes-were deleted along with the dependency, so the invariant inverts: nothing in-the server may import LangChain, and it must not be declared or installed.+were deleted along with the dependency. The server environment must neither+import nor install LangChain. The isolated mobile-use subprocess has one+explicit callback adapter exception in its own dependency environment.The AST walk (rather than a text grep) is deliberate -- it catches``importlib.import_module("langchain_core")`` and ``__import__(...)``, which a@@ -28,6 +29,13 @@ SERVER_ROOT = Path(__file__).resolve().parents[2]FORBIDDEN_PREFIXES = ("langchain", "langgraph", "langsmith", "deepagents")+# This entrypoint is launched with the mobile engine's Python, never imported+# by the server. Permit only its progress callback adapter, not arbitrary+# LangChain usage elsewhere in the mobile plugin or the server.+ISOLATED_IMPORTS = {+ ("nodes/mobile/runtime/worker.py", "main", "langchain_core.callbacks"),+}+class _ImportUse(NamedTuple):module: str@@ -98,11 +106,14 @@ def _imports(path: Path) -> Iterable[_ImportUse]:def _production_sources() -> list[Path]:- return [- path- for path in SERVER_ROOT.rglob("*.py")- if "tests" not in path.parts and ".venv" not in path.parts- ]+ # Installed mobile engines are isolated subprocess dependencies, not server+ # source. Prune runtime trees before walking their SDKs and virtualenvs.+ excluded = {"tests", ".venv", ".opencompany", ".machina", "__pycache__"}+ sources = []+ for root, dirs, files in os.walk(SERVER_ROOT):+ dirs[:] = [name for name in dirs if name not in excluded]+ sources.extend(Path(root) / name for name in files if name.endswith(".py"))+ return sourcesdef test_no_module_imports_langchain():@@ -114,6 +125,8 @@ def test_no_module_imports_langchain():for path in sourcesfor use in _imports(path)if use.module.startswith(FORBIDDEN_PREFIXES)+ and (path.relative_to(SERVER_ROOT).as_posix(), use.scope, use.module)+ not in ISOLATED_IMPORTS]assert not violations, (diff --git a/server/tests/test_no_raw_prints.py b/server/tests/test_no_raw_prints.pyindex 8e0ea5e1..bc9b3f3d 100644--- a/server/tests/test_no_raw_prints.py+++ b/server/tests/test_no_raw_prints.py@@ -23,6 +23,7 @@ and walks each ``ast.Call`` node looking for bare ``print(...)``.from __future__ import annotationsimport ast+import osfrom pathlib import Pathfrom typing import List, Tuple@@ -30,6 +31,8 @@ SERVER_ROOT = Path(__file__).resolve().parents[1]# Directories whose ``print()`` calls are out of scope._EXCLUDED_DIRS = {+ ".opencompany", # installed runtimes belong to isolated subprocesses+ ".machina", # legacy runtime data directory".venv","tests", # tests themselves can print freely"scripts", # CLI smoke tests are intentional stdout tools@@ -53,17 +56,17 @@ _SANCTIONED: List[Tuple[str, str]] = [# its pins. Same role as the Temporal installer above.("nodes/browser/_install.py", "_main"),("nodes/browser/_pin.py", "main"),+ # JSON wire replies to the parent process, not application log messages.+ ("nodes/mobile/runtime/device_server.py", "main"),]def _iter_python_files() -> List[Path]:"""Yield every .py file under ``server/`` outside the exclusion set."""files: List[Path] = []- for path in SERVER_ROOT.rglob("*.py"):- rel_parts = path.relative_to(SERVER_ROOT).parts- if any(part in _EXCLUDED_DIRS for part in rel_parts):- continue- files.append(path)+ for root, dirs, names in os.walk(SERVER_ROOT):+ dirs[:] = [name for name in dirs if name not in _EXCLUDED_DIRS]+ files.extend(Path(root) / name for name in names if name.endswith(".py"))return filesdiff --git a/server/tests/test_plugin_contract.py b/server/tests/test_plugin_contract.pyindex 43bc763e..4808b508 100644--- a/server/tests/test_plugin_contract.py+++ b/server/tests/test_plugin_contract.py@@ -348,10 +348,11 @@ class TestNeedsCanvasContract:for cls in _all_plugin_classes():if not issubclass(cls, ToolNode):continue- if cls.type in {"agentBuilder", "taskManager"}:+ # Android needs edges to resolve its optional connected model.+ if cls.type in {"agentBuilder", "taskManager", "android_tool"}:continueassert cls.needs_canvas is False, (- f"{cls.__qualname__} declares needs_canvas=True but isn't agentBuilder. "+ f"{cls.__qualname__} declares needs_canvas=True but isn't allowlisted. "f"Add the plugin to the canvas-aware allowlist in the "f"AgentWorkflow tool-dispatch comment if this is intentional, "f"or remove the override if accidental."