Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix(browser): pass group_id="new" on first call (DOMShell 2.0.2 deprecation migration)

apirenobe62f843b533
diff --git a/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py b/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
index 58017d1a3..8c63f5967 100644
--- a/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
+++ b/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
@@ -1106,8 +1106,18 @@ def test_call_execute_includes_group_id_when_lane_is_set():
assert arguments == {"command": "ls /", "group_id": "lane-7"}
-def test_call_execute_omits_group_id_when_lane_is_none():
- """First-call shape: no stored lane → no group_id; DOMShell auto-assigns."""
+def test_call_execute_passes_group_id_new_when_lane_is_none():
+ """First-call shape: no stored lane → ``group_id="new"``; DOMShell
+ creates an isolated lane and returns the id, which we capture for
+ next time.
+
+ Migration note (PR #308 follow-up to DOMShell 2.0.2): we used to omit
+ ``group_id`` on the first call entirely, which DOMShell 2.x mapped
+ to a fresh lane silently. 2.0.2 deprecated that path — omitting now
+ emits a [DEPRECATION] warning on every reply (will be a hard error
+ in 3.0.0). Passing ``"new"`` makes the intent explicit and silences
+ the warning.
+ """
sess = Session() # lane is None
fake_tool = AsyncMock(return_value=_make_result("✓\n[lane: brand-new]"))
@@ -1128,7 +1138,7 @@ def test_call_execute_omits_group_id_when_lane_is_none():
_aio.run(backend._call_execute("ls /", session=sess))
arguments = fake_tool.call_args.args[1]
- assert "group_id" not in arguments
+ assert arguments.get("group_id") == "new"
# The auto-assigned lane gets captured for next time.
assert sess.domshell_lane_id == "brand-new"
diff --git a/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py b/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
index 8d81aed2a..7f5624c76 100644
--- a/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
+++ b/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
@@ -499,15 +499,23 @@ async def _call_execute(
global _daemon_session, _daemon_read, _daemon_write
arguments: dict[str, Any] = {"command": command}
- # Reuse the previously-captured DOMShell lane so this call lands in the
- # same Chrome tab-group as the prior commands in this session. Without
- # this, every fresh stdio ClientSession would be assigned a brand-new
- # lane and `page open` / `fs ls` etc. would run in disjoint browser
- # state. The very first call leaves group_id unset so DOMShell
- # auto-assigns; _capture_lane stores that id on the session for the
- # next call.
+ # Lane handling for non-daemon mode: every fresh stdio ClientSession
+ # would otherwise be assigned a brand-new lane, scattering `page open`
+ # / `fs ls` / etc. across disjoint browser state. So we name the lane
+ # explicitly on every call:
+ # • subsequent calls → group_id=<previously captured lane id>
+ # • very first call → group_id="new" — DOMShell creates a fresh
+ # isolated lane and returns its id in the [lane: ...] marker,
+ # which `_capture_lane` stores on the session for next time.
+ # DOMShell 2.0.2 deprecated omitting `group_id` entirely (emits a
+ # [DEPRECATION] warning in the reply; hard error in 3.0.0). Passing
+ # "new" on the first call matches our actual intent — we want our own
+ # private lane, not the shared one — and silences the deprecation
+ # warning across every REPL session.
if session is not None and getattr(session, "domshell_lane_id", None):
arguments["group_id"] = session.domshell_lane_id
+ else:
+ arguments["group_id"] = "new"
if use_daemon and _daemon_session is not None:
# Use persistent daemon connection