Repository navigation
Description
What is declared
The CLI option says the agent is restricted to one package:
artemis/artemis/interfaces/cli/commands/run.py
Lines 179 to 186 in 351ca84
| locked_app_package: Annotated[ | |
| str | None, | |
| typer.Option( | |
| "--locked-app", | |
| "-a", | |
| help="Optional Android package name to restrict the agent to.", | |
| ), | |
| ] = None, |
--locked-app,-a: "Optional Android package name to restrict the agent to."
The MCP tool description says the same, more strongly:
artemis/mcp_server/tools/task_runner.py
Lines 260 to 261 in 351ca84
| locked_app_package: Optional package name to lock execution to; the | |
| agent auto-launches it and restricts actions to that app. |
"Optional package name to lock execution to; the agent auto-launches it and restricts actions to that app."
and the SDK docstring: ".with_locked_app_package() to restrict execution to a specific app"
artemis/third_party/mobile_use/sdk/agent.py
Line 280 in 351ca84
| - .with_locked_app_package() to restrict execution to a specific app |
What the code does instead
The only use of the value is _prepare_app_lock, which launches the package once before the run and stores the result. If the launch fails, it logs a warning and the run continues:
artemis/third_party/mobile_use/sdk/agent.py
Lines 851 to 870 in 351ca84
| async def _prepare_app_lock(self, task: Task, context: ArtemisContext): | |
| """Prepare app lock by launching the locked app if specified.""" | |
| if not task.request.locked_app_package: | |
| return | |
| task_name = task.get_name() | |
| logger.info(f"[{task_name}] Preparing app lock for: {task.request.locked_app_package}") | |
| app_lock_status = await _handle_initial_app_launch( | |
| ctx=context, locked_app_package=task.request.locked_app_package | |
| ) | |
| if context.execution_setup is None: | |
| context.execution_setup = ExecutionSetup(app_lock_status=app_lock_status) | |
| else: | |
| context.execution_setup.app_lock_status = app_lock_status | |
| if app_lock_status.locked_app_initial_launch_success is False: | |
| error = app_lock_status.locked_app_initial_launch_error | |
| logger.warning(f"[{task_name}] Failed to launch locked app: {error}") |
The stored status has an accessor, ExecutionSetup.get_locked_app_package(), but nothing calls it:
artemis/third_party/mobile_use/context.py
Lines 89 to 98 in 351ca84
| app_lock_status: AppLaunchResult | None = None | |
| def get_locked_app_package(self) -> str | None: | |
| """Get the locked app package name if app locking is enabled. | |
| Returns: | |
| The locked app package name, or None if app locking is not enabled. | |
| """ | |
| if self.app_lock_status: | |
| return self.app_lock_status.locked_app_package |
I could not find a per-step foreground check, a tool filter, or prompt text in either the Flash runner or the Pro graph that refers to the locked package. After the first launch the agent can open or act in any other app, and nothing detects it.
(The builder's own docstring is accurate - "ensures the specified app is launched and in the foreground before the agentic loop starts" - so the gap is between that behaviour and what the CLI help, MCP description and SDK docstring promise.)
artemis/third_party/mobile_use/sdk/builders/task_request_builder.py
Lines 84 to 94 in 351ca84
| def with_locked_app_package(self, package_name: str) -> Self: | |
| """Set the app package to lock execution to. | |
| This ensures the specified app is launched and in the foreground before | |
| the agentic loop starts. | |
| Args: | |
| package_name: Package name (Android, e.g., 'com.whatsapp') | |
| """ | |
| self._locked_app_package = package_name | |
| return self |
What a user would expect
Passing --locked-app com.example.app (or locked_app_package over MCP) keeps the agent's actions inside that app for the whole run, or stops the run if it leaves or if the app cannot be launched.
Suggested fix
Either of:
- Enforce it: after each action (or in the pre-action check), compare the foreground package with
ctx.execution_setup.get_locked_app_package(); on a mismatch relaunch the locked app or end the run with a clear status, and fail the run when the initial launch fails instead of warning. - If launch-only is the intended behaviour, reword the CLI help, the MCP tool description and the
sdk/agent.pydocstring to say the app is launched at the start and the agent is not confined to it.
This is a reading of the code, not a run.
Disclosure: this finding came from an automated review of the repository's code with a tool I am developing, and was re-checked by a second, slower pass of the same kind; nothing was run.
Activity