Skip to content

The agent that grows with you

refactor(bot-screen): drop the agent-side handoff actions; takeover is always human-initiated

teknium188bd29213b51
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.ts
index fd860551e2d..7efc070db02 100644
--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts
+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts
@@ -270,7 +270,6 @@ type BotsMessages = {
otherControls: string
agentControls: string
controlTaken: string
- handoffRequested: string
}
/** Bot-scoped scheduled jobs. Generic scheduling chrome (weekday names,
@@ -542,7 +541,6 @@ const en: BotsMessages = {
otherControls: 'Another viewer is in control',
agentControls: 'Bot is in control',
controlTaken: 'Another viewer took control. Watching only.',
- handoffRequested: 'Bot needs you'
},
cron: {
filterHint:
@@ -809,7 +807,6 @@ const ja: BotsMessages = {
otherControls: '別のビューアが操作中',
agentControls: 'ボットが操作中',
controlTaken: '別のビューアが操作を引き継ぎました。閲覧のみ。',
- handoffRequested: 'ボットが助けを求めています'
},
cron: {
filterHint:
@@ -1071,7 +1068,6 @@ const zh: BotsMessages = {
otherControls: '另一位查看者正在控制',
agentControls: '机器人正在控制',
controlTaken: '另一位查看者已接管控制。仅可观看。',
- handoffRequested: '机器人需要你'
},
cron: {
filterHint:
@@ -1333,7 +1329,6 @@ const zhHant: BotsMessages = {
otherControls: '另一位檢視者正在控制',
agentControls: '機器人正在控制',
controlTaken: '另一位檢視者已接手控制。僅可觀看。',
- handoffRequested: '機器人需要你'
},
cron: {
filterHint:
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts b/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
index 671fac03dd7..90d29fc45bf 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
+++ b/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
@@ -24,7 +24,6 @@ export interface DisplayLease {
viewer_hash?: null | string
since: number
reason: string
- pending_handoff: null | string
/** Monotonic per transition; a lower epoch is an older snapshot, never newer truth. */
epoch?: number
}
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-install-retention.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-install-retention.test.tsx
index 65b5ccae012..7c8e1a32cda 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-install-retention.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-install-retention.test.tsx
@@ -77,7 +77,7 @@ const status: DisplayStatus = {
socket: null,
geometry: '1440x900',
install_command: 'sudo apt-get install -y tigervnc-standalone-server',
- lease: { holder: 'agent', viewer_id: null, pending_handoff: null, since: 1, reason: '' }
+ lease: { holder: 'agent', viewer_id: null, since: 1, reason: '' }
}
beforeEach(() => {
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
index 00b65c11e8f..7a43654c1ed 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
@@ -68,7 +68,7 @@ const status: DisplayStatus = {
socket: '/tmp/rfb.sock',
geometry: '1440x900',
install_command: null,
- lease: { holder: 'agent', viewer_id: null, pending_handoff: null, since: 1, reason: '' }
+ lease: { holder: 'agent', viewer_id: null, since: 1, reason: '' }
}
beforeEach(() => {
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane-lifecycle.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane-lifecycle.test.tsx
index 53e89ad956e..87221bb08d2 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-pane-lifecycle.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane-lifecycle.test.tsx
@@ -107,7 +107,7 @@ const status: DisplayStatus = {
socket: '/tmp/rfb.sock',
geometry: '1440x900',
install_command: null,
- lease: { holder: 'human', viewer_id: 'this-viewer', pending_handoff: null, since: 1, reason: '' }
+ lease: { holder: 'human', viewer_id: 'this-viewer', since: 1, reason: '' }
}
beforeEach(() => {
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane-status-events.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane-status-events.test.tsx
index 7adad053f1f..a3dec1810f8 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-pane-status-events.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane-status-events.test.tsx
@@ -78,7 +78,7 @@ const stopped: DisplayStatus = {
socket: null,
geometry: '1440x900',
install_command: null,
- lease: { holder: 'agent', viewer_id: null, viewer_hash: null, pending_handoff: null, since: 1, reason: '' }
+ lease: { holder: 'agent', viewer_id: null, viewer_hash: null, since: 1, reason: '' }
}
const running: DisplayStatus = { ...stopped, running: true, pid: 42, display: ':20' }
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
index 6754fc08d49..08730758923 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
@@ -357,12 +357,8 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {
<span className="font-medium">{t.screen.title}</span>
{status?.display ? <span className="text-muted-foreground">{status.display} · {status.geometry}</span> : null}
<span className="grow" />
- {lease?.pending_handoff ? (
- <span className="rounded bg-amber-500/15 px-2 py-0.5 text-amber-600 dark:text-amber-400" title={lease.pending_handoff}>
- <Codicon name="bell" /> {t.screen.handoffRequested}
- </span>
- ) : lease?.holder === 'human' && lease.reason ? (
- // The agent's ask stays readable WHILE the human acts, not only before Take over.
+ {lease?.holder === 'human' && lease.reason ? (
+ // Why control was taken stays readable while the human acts.
<span className="max-w-[40%] truncate rounded bg-amber-500/15 px-2 py-0.5 text-amber-600 dark:text-amber-400" title={lease.reason}>
<Codicon name="bell" /> {lease.reason}
</span>
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-state.test.ts b/apps/desktop/src/plugins/hermes-bots/screen-state.test.ts
index ae4178c8a41..2d0f5422aa1 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-state.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/screen-state.test.ts
@@ -15,7 +15,7 @@ import { $screenState, beginScreenStatusRequest, screenStateFor, setScreenLease,
const bot: RosterRow = { name: 'ops' }
-const agent: DisplayLease = { holder: 'agent', viewer_id: null, viewer_hash: null, since: 1, reason: '', pending_handoff: null, epoch: 3 }
+const agent: DisplayLease = { holder: 'agent', viewer_id: null, viewer_hash: null, since: 1, reason: '', epoch: 3 }
const human: DisplayLease = { ...agent, holder: 'human', viewer_hash: 'abc123abc123', epoch: 4 }
const statusWith = (lease: DisplayLease): DisplayStatus => ({
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-state.ts b/apps/desktop/src/plugins/hermes-bots/screen-state.ts
index c7d3be77abc..2f4045c460a 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-state.ts
+++ b/apps/desktop/src/plugins/hermes-bots/screen-state.ts
@@ -91,8 +91,7 @@ export function setScreenLease(bot: RosterRow, lease: DisplayLease): void {
prev?.lease &&
prev.lease.holder === lease.holder &&
prev.lease.viewer_id === lease.viewer_id &&
- prev.lease.viewer_hash === lease.viewer_hash &&
- prev.lease.pending_handoff === lease.pending_handoff
+ prev.lease.viewer_hash === lease.viewer_hash
) {
return
}
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx
index 5e4243435a6..6210fca8ec0 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx
@@ -80,7 +80,7 @@ const status: DisplayStatus = {
socket: '/tmp/rfb.sock',
geometry: '1440x900',
install_command: null,
- lease: { holder: 'agent', viewer_id: null, viewer_hash: null, pending_handoff: null, since: 1, reason: '' }
+ lease: { holder: 'agent', viewer_id: null, viewer_hash: null, since: 1, reason: '' }
}
beforeEach(() => {
diff --git a/model_tools.py b/model_tools.py
index 1034bbd1805..4193fb22106 100644
--- a/model_tools.py
+++ b/model_tools.py
@@ -374,16 +374,6 @@ def _rewrite_browser_navigate(td: Dict[str, Any], available: set) -> Optional[Di
return _fn_def({**td["function"], "description": desc})
-def _rewrite_computer_use(td: Dict[str, Any], available: set) -> Optional[Dict[str, Any]]:
- """Strip the Bot Screen handoff (`request_handoff` / `wait_for_human`) where no Bot Desktop can exist
- (macOS, Windows): the model would otherwise learn actions that cannot succeed on this host."""
- from tools.bot_desktop.runtime import is_supported_host
- from tools.computer_use.schema import schema_for_host
- if is_supported_host():
- return td
- return _fn_def({**td["function"], **schema_for_host(supported=False)})
-
-
def _rewrite_browser_exec(td: Dict[str, Any], available: set) -> Optional[Dict[str, Any]]:
"""browser_exec runs arbitrary host Python: a session without the terminal surface
must not regain host execution via the browser toolset. Session-level gate rather
@@ -471,7 +461,6 @@ _DYNAMIC_SCHEMA_REWRITERS = {
"browser_vault_list": _rewrite_browser_vault,
"browser_vault_fill": _rewrite_browser_vault,
"delegate_task": _rewrite_delegate_task,
- "computer_use": _rewrite_computer_use,
}
diff --git a/tests/hermes_cli/test_bot_desktop_screen_stop.py b/tests/hermes_cli/test_bot_desktop_screen_stop.py
index 33f661aed50..84542ea6202 100644
--- a/tests/hermes_cli/test_bot_desktop_screen_stop.py
+++ b/tests/hermes_cli/test_bot_desktop_screen_stop.py
@@ -16,4 +16,3 @@ def test_screen_stop_hands_back_even_when_the_desktop_has_already_exited():
args = parser.parse_args(['screen', 'stop'])
assert args.screen_func(args) == 0
assert lease.get().holder == lease.AGENT
- assert lease.wait_for_release(timeout=0)
diff --git a/tests/tools/test_bot_desktop_lease.py b/tests/tools/test_bot_desktop_lease.py
index 4a763ddb6f2..08cc9922fa2 100644
--- a/tests/tools/test_bot_desktop_lease.py
+++ b/tests/tools/test_bot_desktop_lease.py
@@ -56,15 +56,8 @@ def test_computer_use_refuses_every_action_while_a_human_holds_the_screen(monkey
res = json.loads(tool.handle_computer_use({"action": action, "text": "pw"}))
assert res["code"] == "human_has_control", action
assert calls == [], "the driver is never touched while the human may be typing a credential"
-
- # Handoff round trip: the agent asks, the human takes over and hands back, the agent is unblocked.
- asked = json.loads(tool.handle_computer_use({"action": "request_handoff", "reason": "log in"}))
- assert asked["ok"] and asked["state"]["pending_handoff"] == "log in"
- lease.acquire("human", reason="log in")
- assert lease.get().pending_handoff is None
lease.release("human")
- done = json.loads(tool.handle_computer_use({"action": "wait_for_human", "seconds": 1}))
- assert done["ok"] and done["state"]["holder"] == lease.AGENT
+ assert lease.get().holder == lease.AGENT
def test_lease_authority_is_shared_across_processes(tmp_path):
@@ -153,23 +146,22 @@ def test_unreadable_lease_file_fails_closed_and_takeover_keeps_the_agents_reason
lease.release(profile_key=home)
assert lease.get(profile_key=home).holder == lease.AGENT
- lease.request_handoff("log in to the bank, 2FA on your phone", profile_key=home)
- held = lease.acquire("desk-1", profile_key=home)
- assert held.pending_handoff is None and held.reason == "log in to the bank, 2FA on your phone"
+ held = lease.acquire("desk-1", reason="log in to the bank, 2FA on your phone", profile_key=home)
+ assert held.reason == "log in to the bank, 2FA on your phone"
assert hermes_home_key(home) # sanity: the key derivation used by the bridge is available
def test_lease_works_without_fcntl(tmp_path):
- """Windows and fcntl-less hosts: ``computer_use`` imports the lease (via handoff) on EVERY call, so a
- module-level fcntl dependency turns every desktop action into ModuleNotFoundError there. The file
- semantics must still work; only the cross-process lock degrades. Subprocess so the module cache is clean."""
+ """Windows and fcntl-less hosts: ``computer_use`` imports the lease on EVERY call, so a module-level
+ fcntl dependency turns every desktop action into ModuleNotFoundError there. The file semantics must
+ still work; only the cross-process lock degrades. Subprocess so the module cache is clean."""
import os
import subprocess
import sys
probe = ("import sys; sys.modules['fcntl'] = None; sys.path.insert(0, %r)\n"
"from tools.bot_desktop import lease\n"
- "import tools.computer_use.handoff\n"
+ "import tools.computer_use.tool\n"
"assert lease.get().holder == lease.AGENT\n"
"assert lease.acquire('v1').holder == lease.HUMAN\n"
"assert lease.get().holder == lease.HUMAN\n"
diff --git a/tests/tools/test_computer_use_handoff_wait.py b/tests/tools/test_computer_use_handoff_wait.py
deleted file mode 100644
index 29811d85805..00000000000
--- a/tests/tools/test_computer_use_handoff_wait.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""wait_for_human answers an unanswered handoff early instead of blocking the whole timeout, and still
-waits the full timeout once a human actually holds the screen."""
-
-from __future__ import annotations
-
-import json
-import threading
-import time
-
-import pytest
-
-from tools.bot_desktop import lease
-from tools.computer_use.handoff import handle_handoff
-
-
[email protected](autouse=True)
-def _fresh_lease():
- lease._reset_for_tests()
- yield
- lease._reset_for_tests()
-
-
-def test_wait_for_human_returns_no_takeover_when_nobody_answers_but_waits_out_a_real_takeover():
- handle_handoff("request_handoff", {"reason": "log in"})
- t0 = time.monotonic()
- res = json.loads(handle_handoff("wait_for_human", {"seconds": 30, "grace": 0.2}))
- assert res["code"] == "no_takeover" and res["state"]["pending_handoff"] == "log in"
- assert time.monotonic() - t0 < 10, "an unanswered request must not run the full timeout"
-
- # A human takes over inside the grace window and hands back later: the wait outlives the grace.
- def _take_then_release():
- time.sleep(0.1)
- lease.acquire("viewer-1")
- time.sleep(0.6)
- lease.release("viewer-1")
- threading.Thread(target=_take_then_release, daemon=True).start()
- res = json.loads(handle_handoff("wait_for_human", {"seconds": 30, "grace": 0.3}))
- assert res["ok"] and res["state"]["holder"] == lease.AGENT
diff --git a/tests/tools/test_computer_use_schema_host.py b/tests/tools/test_computer_use_schema_host.py
deleted file mode 100644
index abc89de75b7..00000000000
--- a/tests/tools/test_computer_use_schema_host.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""The computer_use schema only teaches the Bot Screen handoff (`request_handoff` / `wait_for_human`,
-'take over this screen from the Hermes Desktop app') on hosts that can have a Bot Desktop; elsewhere
-the model would learn actions that can never succeed."""
-
-from __future__ import annotations
-
-import json
-
-from tools.computer_use.schema import COMPUTER_USE_SCHEMA, schema_for_host
-
-_HANDOFF = ("request_handoff", "wait_for_human")
-
-
-def _actions(schema) -> list[str]:
- return schema["parameters"]["properties"]["action"]["enum"]
-
-
-def test_unsupported_host_schema_has_no_handoff_vocabulary():
- schema = schema_for_host(supported=False)
- text = json.dumps(schema)
- assert not any(action in text for action in _HANDOFF), text
- assert "take over this screen" not in text
- assert "reason" not in schema["parameters"]["properties"] # request_handoff's only parameter
- assert "grace" not in schema["parameters"]["properties"] # wait_for_human's only parameter
- # Everything else survives untouched.
- assert set(_actions(schema)) == set(_actions(COMPUTER_USE_SCHEMA)) - set(_HANDOFF)
- assert schema["parameters"]["required"] == ["action"]
-
-
-def test_supported_host_schema_keeps_the_handoff_and_is_the_frozen_schema():
- schema = schema_for_host(supported=True)
- assert set(_HANDOFF) <= set(_actions(schema))
- assert schema is COMPUTER_USE_SCHEMA # byte-frozen value: no per-call copy on the common path
diff --git a/tests/tui_gateway/test_display_watch.py b/tests/tui_gateway/test_display_watch.py
index ffcf7215810..85c152eff74 100644
--- a/tests/tui_gateway/test_display_watch.py
+++ b/tests/tui_gateway/test_display_watch.py
@@ -46,17 +46,17 @@ def _lease_events(events, **want):
return [p for ev, p in events if ev == "display.lease" and all(p["lease"].get(k) == v for k, v in want.items())]
-def test_handoff_requested_in_another_process_is_broadcast(tmp_path, monkeypatch):
+def test_takeover_in_another_process_is_broadcast(tmp_path, monkeypatch):
import tui_gateway.server as server
from hermes_constants import hermes_home_key
home = tmp_path / "home"
home.mkdir()
events = _watching(server, home, monkeypatch)
- _other_process(home, 'lease.request_handoff("probe")')
+ _other_process(home, 'lease.acquire("cli-viewer", reason="probe")')
- assert _wait_for(lambda: _lease_events(events, pending_handoff="probe")), events
- (payload,) = _lease_events(events, pending_handoff="probe")
+ assert _wait_for(lambda: _lease_events(events, reason="probe")), events
+ (payload,) = _lease_events(events, reason="probe")
assert payload["profile_key"] == hermes_home_key(home)
diff --git a/tools/bot_desktop/lease.py b/tools/bot_desktop/lease.py
index fbec8dc5f5d..b4e3533f85c 100644
--- a/tools/bot_desktop/lease.py
+++ b/tools/bot_desktop/lease.py
@@ -34,7 +34,6 @@ logger = logging.getLogger(__name__)
AGENT = "agent"
HUMAN = "human"
-_POLL_SECONDS = 0.25
class HumanHasControl(RuntimeError):
@@ -47,7 +46,6 @@ class Lease:
viewer_id: Optional[str] = None
since: float = field(default_factory=time.time)
reason: str = ""
- pending_handoff: Optional[str] = None # agent's reason for asking, until the human takes over
epoch: int = 0
def as_dict(self) -> Dict[str, object]:
@@ -175,8 +173,7 @@ def acquire(viewer_id: str, *, profile_key: Optional[str] = None, reason: str =
# The agent's ask ("please log in to X") stays as the takeover reason: the human needs it
# on screen WHILE they act, not only before they clicked Take over.
lease.holder, lease.viewer_id, lease.since = HUMAN, viewer_id, time.time()
- lease.reason = reason or lease.pending_handoff or ""
- lease.pending_handoff = None
+ lease.reason = reason or ""
return True
return _transition(profile_key, _m)
@@ -191,45 +188,10 @@ def release(viewer_id: Optional[str] = None, *, profile_key: Optional[str] = Non
logger.info("bot-desktop lease: release by %r ignored, another viewer holds", viewer_id)
return False
lease.holder, lease.viewer_id, lease.since, lease.reason = AGENT, None, time.time(), ""
- lease.pending_handoff = None # "hand back" answers an open request even if nobody formally took over
return True
return _transition(profile_key, _m)
-def request_handoff(reason: str, *, profile_key: Optional[str] = None) -> Lease:
- """Agent asks a human to take over (login, 2FA, CAPTCHA, payment). Recorded so the UI can show
- why and the bridge can page the user; control itself still flips only on ``acquire``."""
- def _m(lease: Lease) -> bool:
- lease.pending_handoff = reason
- return True
- return _transition(profile_key, _m)
-
-
-def wait_for_release(*, timeout: float, profile_key: Optional[str] = None) -> bool:
- """Block until the agent holds the lease (and no handoff is pending) or ``timeout`` elapses.
- True when control is back with the agent. Polls the file so a release made by another process
- is seen; the local Condition just shortens the wait for same-process transitions."""
- return _wait_until(lambda lease: lease.holder == AGENT and lease.pending_handoff is None, timeout, profile_key)
-
-
-def wait_for_takeover_or_release(*, timeout: float, profile_key: Optional[str] = None) -> bool:
- """False when, after ``timeout``, the agent still holds with a handoff pending: nobody answered."""
- return _wait_until(lambda lease: lease.holder == HUMAN or lease.pending_handoff is None, timeout, profile_key)
-
-
-def _wait_until(done: Callable[[Lease], bool], timeout: float, profile_key: Optional[str]) -> bool:
- path = _path(profile_key)
- deadline = time.monotonic() + timeout
- while True:
- if done(_read(path)):
- return True
- remaining = deadline - time.monotonic()
- if remaining <= 0:
- return False
- with _lock:
- _lock.wait(min(remaining, _POLL_SECONDS))
-
-
def human_holds(profile_key: Optional[str] = None) -> bool:
return get(profile_key).holder == HUMAN
@@ -246,8 +208,7 @@ def assert_agent_may_act(profile_key: Optional[str] = None) -> Lease:
if lease.holder == HUMAN:
raise HumanHasControl(
"A human has taken over this desktop (they may be entering a credential). Screen actions and "
- "captures are refused until they hand control back; call computer_use action='wait_for_human' "
- "to block until then.")
+ "captures are refused until they hand control back. Tell the user what you need in your reply.")
return lease
diff --git a/tools/browser_tool_session.py b/tools/browser_tool_session.py
index 1366a415ee7..0fb9c27c741 100644
--- a/tools/browser_tool_session.py
+++ b/tools/browser_tool_session.py
@@ -610,7 +610,7 @@ def run_fenced(session_info: Dict[str, Any], fn: Callable[[], Dict[str, Any]]) -
if _bd_lease.get().epoch != admitted.epoch:
return {"success": False, "code": "human_has_control",
"error": "A human took over the bot's screen while this browser command ran; its result was "
- "discarded. Call computer_use action='wait_for_human' to block until they hand back."}
+ "discarded. Tell the user what you need; retry once they hand back."}
return result
diff --git a/tools/computer_use/handoff.py b/tools/computer_use/handoff.py
deleted file mode 100644
index bdd38acbb1a..00000000000
--- a/tools/computer_use/handoff.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""Human handoff actions for ``computer_use`` on a Bot Desktop: ``request_handoff`` asks the person to
-take over the screen (login, 2FA, CAPTCHA, payment) and ``wait_for_human`` blocks until control is
-back. Both are answered without touching cua-driver, so a human typing a credential is never
-captured.
-
-The Desktop pane shows the request (the gateway broadcasts the lease change). Reaching the person
-anywhere else is the model's job: it relays the ask in its reply, which is what lands in the chat
-surface the user is actually on. This module only records intent on the lease and waits.
-"""
-
-from __future__ import annotations
-
-import json
-from typing import Any, Dict
-
-from tools.bot_desktop import lease as _lease
-
-HANDOFF_ACTIONS = frozenset({"request_handoff", "wait_for_human"})
-_DEFAULT_WAIT_SECONDS = 600.0
-_MAX_WAIT_SECONDS = 1800.0
-_DEFAULT_GRACE_SECONDS = 60.0
-
-
-def handle_handoff(action: str, args: Dict[str, Any]) -> str:
- if action == "request_handoff":
- reason = str(args.get("reason") or "The agent needs you to complete a step on its screen.").strip()
- _lease.request_handoff(reason)
- return json.dumps({
- "ok": True, "action": action, "state": _lease.get().as_dict(),
- "next": "Hermes Desktop now shows 'Bot needs you' on this bot's Screen. Tell the user in your "
- "reply what to do and that they can take over from Bots > Screen, then call "
- "computer_use action='wait_for_human' to block until they hand control back and "
- "re-capture before continuing — the screen state is whatever they left."})
- timeout = min(_MAX_WAIT_SECONDS, max(1.0, float(args.get("seconds") or _DEFAULT_WAIT_SECONDS)))
- grace = min(timeout, max(0.0, float(args.get("grace") or _DEFAULT_GRACE_SECONDS)))
- # Nobody has taken over yet: give them `grace` to click Take over, then return so the model can chase
- # the user in chat instead of blocking the whole timeout on a request nobody saw. Once a human holds
- # the screen, wait the full timeout for the hand-back.
- if not _lease.wait_for_takeover_or_release(timeout=grace):
- state = _lease.get().as_dict()
- return json.dumps({"ok": False, "action": action, "code": "no_takeover", "state": state,
- "error": f"Nobody took over within {grace:.0f}s. Ask the user in chat to open Bots > Screen and "
- "click Take over, then call wait_for_human again."})
- released = _lease.wait_for_release(timeout=timeout)
- state = _lease.get().as_dict()
- if released:
- return json.dumps({"ok": True, "action": action, "state": state,
- "next": "Control is back with you. Take a fresh capture; do not assume prior state."})
- return json.dumps({"ok": False, "action": action, "code": "still_waiting", "state": state,
- "error": f"No hand-back within {timeout:.0f}s. Call wait_for_human again or ask the user in chat."})
diff --git a/tools/computer_use/schema.py b/tools/computer_use/schema.py
index 9eaf7fbe591..330e5ba4fc0 100644
--- a/tools/computer_use/schema.py
+++ b/tools/computer_use/schema.py
@@ -10,18 +10,6 @@ from __future__ import annotations
from typing import Any, Dict
-# Bot Screen handoff: the human takes the bot's headless Linux screen over from the Hermes Desktop app.
-# Only meaningful where a Bot Desktop can exist (Linux gateway hosts); `schema_for_host` strips it
-# elsewhere so macOS/Windows/seated-Linux models never learn actions that cannot succeed.
-_HANDOFF_ACTIONS = ("request_handoff", "wait_for_human")
-_HANDOFF_ONLY_PROPERTIES = ("reason", "grace")
-_HANDOFF_ACTION_HINT = (
- " When a login, 2FA, CAPTCHA or payment step needs the human, call "
- "`request_handoff` (with `reason`) so they can take over this screen from the Hermes "
- "Desktop app, then `wait_for_human`; while they hold control every other action is refused."
-)
-_HANDOFF_SECONDS_HINT = " wait_for_human: how long to block for the hand-back (default 600, max 1800)."
-
# One consolidated tool with an `action` discriminator keeps the schema compact
# and the per-turn token cost low. Property groups: capture (mode, app, pid,
# window_id) / targeting (element, coordinate, button, modifiers) / drag / scroll /
@@ -44,14 +32,12 @@ _PROPERTIES: Dict[str, Any] = {
"list_apps",
"list_windows",
"focus_app",
- "request_handoff",
- "wait_for_human",
],
"description": (
"Which action to perform. `capture` is free (no side effects). All other actions "
"require approval unless auto-approved. Use `set_value` for select/popup elements and "
"sliders — it selects the matching option directly without opening the native menu (no "
- "focus steal)." + _HANDOFF_ACTION_HINT
+ "focus steal)."
),
},
"mode": {
@@ -155,15 +141,13 @@ _PROPERTIES: Dict[str, Any] = {
),
},
"text": {"type": "string", "description": "Text to type (respects the current layout)."},
- "reason": {"type": "string", "description": "request_handoff: one sentence telling the human what to do on the screen (e.g. 'Sign in to LinkedIn and complete 2FA')."},
"keys": {
"type": "string",
"description": (
"Key combo, e.g. 'cmd+s', 'ctrl+alt+t', 'return', 'escape', 'tab'. Use '+' to combine."
),
},
- "seconds": {"type": "number", "description": "wait: seconds to pause (max 30)." + _HANDOFF_SECONDS_HINT},
- "grace": {"type": "number", "description": "wait_for_human: seconds to wait for someone to take over before returning no_takeover (default 60); once a human holds control the full `seconds` applies."},
+ "seconds": {"type": "number", "description": "wait: seconds to pause (max 30)."},
"raise_window": {
"type": "boolean",
"description": (
@@ -223,18 +207,3 @@ def get_computer_use_schema() -> Dict[str, Any]:
"""Return the generic OpenAI function-calling schema."""
return COMPUTER_USE_SCHEMA
-
-def schema_for_host(*, supported: bool) -> Dict[str, Any]:
- """The frozen schema on hosts that can run a Bot Desktop; elsewhere the same schema without the
- handoff actions, their parameters and their copy. Pure: the host decision is the caller's."""
- if supported:
- return COMPUTER_USE_SCHEMA
- props = dict(_PROPERTIES)
- for name in _HANDOFF_ONLY_PROPERTIES:
- props.pop(name)
- action = dict(props["action"])
- action["enum"] = [a for a in action["enum"] if a not in _HANDOFF_ACTIONS]
- action["description"] = action["description"].replace(_HANDOFF_ACTION_HINT, "")
- props["action"] = action
- props["seconds"] = {**props["seconds"], "description": props["seconds"]["description"].replace(_HANDOFF_SECONDS_HINT, "")}
- return {**COMPUTER_USE_SCHEMA, "parameters": {**COMPUTER_USE_SCHEMA["parameters"], "properties": props}}
diff --git a/tools/computer_use/tool.py b/tools/computer_use/tool.py
index c7db871c40a..c93ad23530f 100644
--- a/tools/computer_use/tool.py
+++ b/tools/computer_use/tool.py
@@ -250,9 +250,6 @@ def handle_computer_use(args: Dict[str, Any], **kwargs) -> Any:
if not action:
return json.dumps({"error": "missing `action`"})
session_id = str(kwargs.get("session_id") or "") # approval-state / daemon-mode isolation key
- from tools.computer_use.handoff import HANDOFF_ACTIONS, handle_handoff
- if action in HANDOFF_ACTIONS:
- return handle_handoff(action, args)
# Bot Desktop lease: while a human drives the screen every action, capture included, is refused.
from tools.bot_desktop import lease as _bd_lease
from tools.bot_desktop.runtime import ensure_started_for_tool as _bd_ensure_started
@@ -295,7 +292,7 @@ def handle_computer_use(args: Dict[str, Any], **kwargs) -> Any:
if _bd_lease.get().epoch != admitted.epoch:
raise _bd_lease.HumanHasControl(
"A human took over this desktop while the action ran; its result was discarded. "
- "Re-capture (or call computer_use action='wait_for_human' if they still hold control).")
+ "Tell the user what you need and re-capture once they hand back.")
_fence() # input actions never receive fence=; refuse before the device op starts
result = _dispatch(backend, action, args, fence=_fence)
_fence()
diff --git a/tui_gateway/methods_display_watch.py b/tui_gateway/methods_display_watch.py
index 811e069ecdc..9c5ddb383f1 100644
--- a/tui_gateway/methods_display_watch.py
+++ b/tui_gateway/methods_display_watch.py
@@ -1,9 +1,9 @@
"""Cross-process lease watcher: ``display.lease`` for transitions made OUTSIDE ``hermes serve``.
The lease (``tools.bot_desktop.lease``) lives on disk and is changed by whatever process hosts the
-agent — the messaging gateway's ``request_handoff``, a ``hermes chat`` takeover, a cron worker's
-release. ``lease.on_change`` only fires in the writing process, so ``methods_display``'s in-process
-listener never sees those; the Desktop's "Bot needs you" badge and hero tone stayed stale until the
+agent — a ``hermes computer-use screen`` takeover from the CLI, a cron worker's release.
+``lease.on_change`` only fires in the writing process, so ``methods_display``'s in-process
+listener never sees those; the Desktop's hero tone and pane state stayed stale until the
pane was reopened. One daemon thread stats every served home's ``bot-desktop/lease.json`` (launch
home + ``_served_profile_homes``) every 0.5s and broadcasts the SAME ``display.lease`` payload when
the epoch moves. Bodies are rebound onto server.py's globals (method_ctx.bind_module).
diff --git a/website/docs/user-guide/features/bot-screen.md b/website/docs/user-guide/features/bot-screen.md
index cc53864f55f..0c9914ba7ca 100644
--- a/website/docs/user-guide/features/bot-screen.md
+++ b/website/docs/user-guide/features/bot-screen.md
@@ -100,11 +100,12 @@ with `human_has_control`, captures included. This is a tool-level fence, not an
OS one: the bot runs as the same user as its screen. Don't type secrets into a
bot you wouldn't trust with them.
-The bot can ask for you: when it recognises a login or verification step it
-calls `computer_use` with `action: "request_handoff"` and a reason, the pane
-shows **Bot needs you**, the bot tells you in its reply what it needs (so the
-ask reaches you in whatever chat you are on), and it blocks in
-`action: "wait_for_human"` until you hand back.
+When the bot hits a step it should not do itself (a login, 2FA, a CAPTCHA, a
+payment) it says so in its reply and ends its turn; the ask reaches you in
+whatever chat you are on. Take over when you are ready, do the step, hand back,
+and tell the bot to continue. Nothing blocks on the bot's side while it waits:
+taking over is always yours to start, and a bot never holds a tool call open
+waiting for you.
Two viewers on one screen: the most recent **Take over** wins; the previous
controller drops back to watching.