Skip to content

The agent that grows with you

fix(onboarding): the first-task page opens in the browser on a local backend, also on Windows

alt-glitch534f7259f9f8
diff --git a/agent/onboarding_first_tasks.py b/agent/onboarding_first_tasks.py
index 16e4901bedd..f727778ddb9 100644
--- a/agent/onboarding_first_tasks.py
+++ b/agent/onboarding_first_tasks.py
@@ -26,7 +26,7 @@ OWN_ID = "own"
class FirstTask:
"""``skills`` load first, before the work; an entry ``a|b`` means one of them, whichever fits.
Plugin skills use the ``<plugin>:<skill>`` form skill_view resolves. ``goal`` finishes the
- sentence "Your job: ..."; ``<open>`` in a step is replaced with how this host shows a page."""
+ sentence "Your job: ..."; ``<open>`` in a step and ``<shown>`` in the output are replaced with how this host shows a page."""
id: str
label: str
@@ -113,7 +113,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Write a short Python script, run it in Blender and render one still.",
"Show the render, then offer one variation.",
),
- output="The script and the PNG render in ~/hermes-first-task/; the render shown with desktop_preview.",
+ output="The script and the PNG render in ~/hermes-first-task/; the render <shown>.",
quality="A real Blender render, lit and framed. Never a placeholder.",
done="The render is shown and you said where the script and image are."),
FirstTask(
@@ -125,7 +125,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Show a first version early, then fill it in: what needs attention, what changed, what is next.",
"Offer a morning cron job that sends the brief. Schedule it only on yes.",
),
- output="One designed HTML page in ~/hermes-first-task/, shown with desktop_preview.",
+ output="One designed HTML page in ~/hermes-first-task/, <shown>.",
quality="Every item comes from a connected app and says which one. Nothing invented.",
done="The brief is shown and the morning job is set up or declined."),
FirstTask(
@@ -137,7 +137,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Show a first version early, then fill it in: meetings, threads, work shipped, open loops.",
"End with a short plan for next week built from the open loops.",
),
- output="One designed HTML page in ~/hermes-first-task/, shown with desktop_preview.",
+ output="One designed HTML page in ~/hermes-first-task/, <shown>.",
quality="Every item comes from a connected app and says which one. Nothing invented.",
done="The page is shown with all five parts filled from real data."),
FirstTask(
@@ -174,7 +174,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Show a first version early, then refine the same file.",
"Add one interactive p5js figure that shows the core idea.",
),
- output="One self-contained HTML file in ~/hermes-first-task/, shown with desktop_preview, sources at "
+ output="One self-contained HTML file in ~/hermes-first-task/, <shown>, sources at "
"the end.",
quality="Designed with claude-design. Every claim is cited. The figure responds to input.",
done="The page is shown with the figure working and every source listed."),
@@ -187,7 +187,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Pull out the main ideas, each with a timestamp and a quote.",
"Show a first version early, then lay the ideas out visually, with one figure where it helps.",
),
- output="One self-contained HTML file in ~/hermes-first-task/, shown with desktop_preview; each "
+ output="One self-contained HTML file in ~/hermes-first-task/, <shown>; each "
"timestamp links to that moment in the video.",
quality="Designed with claude-design. Quotes are exact words from the transcript.",
done="The page is shown and every idea has its timestamp and quote."),
@@ -212,7 +212,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Show a first version early with a p5js hero, then refine the same file.",
"Offer one variation.",
),
- output="One self-contained HTML file in ~/hermes-first-task/, shown with desktop_preview.",
+ output="One self-contained HTML file in ~/hermes-first-task/, <shown>.",
quality="Designed with the skills. Real content they gave you, never filler text.",
done="The page is shown and a variation is offered."),
FirstTask(
@@ -224,7 +224,7 @@ FIRST_TASKS: tuple[FirstTask, ...] = (
"Read its entry points and main modules.",
"Draw the architecture page: the modules, how they connect, where to start reading.",
),
- output="One self-contained HTML file in ~/hermes-first-task/, shown with desktop_preview.",
+ output="One self-contained HTML file in ~/hermes-first-task/, <shown>.",
quality="Only modules that are really in the repo, named by their paths.",
done="The page is shown and every box on it maps to a real path."),
)
@@ -239,7 +239,7 @@ OWN_TASK = FirstTask(
"Cut a big ask to a first slice and say so in one line.",
"Show a first version early, then refine it.",
),
- output="Whatever fits the task; a page is one self-contained HTML file shown with desktop_preview.",
+ output="Whatever fits the task; a page is one self-contained HTML file, <shown>.",
quality="Real data only, designed with the skills when it is a page.",
done="The first slice is shown and you said where its files are.")
TASK_BY_ID = {task.id: task for task in FIRST_TASKS}
diff --git a/agent/onboarding_text.py b/agent/onboarding_text.py
index 0db5765fd5d..58ee6e15861 100644
--- a/agent/onboarding_text.py
+++ b/agent/onboarding_text.py
@@ -131,7 +131,7 @@ _HOW_TO_WORK = (
"Connect or install anything once, with exact ids and no searching, then use it.",
"Never search the whole disk.",
"Save every file in ~/hermes-first-task/ and say where it is. No test files.",
- "A page is one self-contained HTML file shown with desktop_preview, unless the task says otherwise.",
+ "A page is one self-contained HTML file, unless the task says otherwise.",
)
_CONNECTORS = (
@@ -157,22 +157,43 @@ _SPARK_LINE = "This machine is built for local models; say so once when it fits
_REMOTE_LINE = "Hermes runs on another computer than the user's: say which machine anything is installed on."
-_OPEN = {"macos": "`open <file>`", "windows": '`start "" <file>`'}
+_PREVIEW_CALL = 'tool_call {"calls":[{"name":"desktop_preview","arguments":{"action":"open","url":"<file>"}}]}'
+# The terminal tool's Git Bash on Windows passes argv literally (MSYS_NO_PATHCONV=1), so Git's `start`
+# wrapper hands cmd a literal `//c` and opens nothing; a single-slash `cmd.exe /c` survives that.
+_OPEN = {"macos": "`open <file>`",
+ "windows": '`cmd.exe /c start "" "<file>"` with the full Windows path (C:/Users/...), never a ~ or /c/ path'}
+_CMD_BANNER = ('Exit 0 with a cmd banner ("Microsoft Windows [Version ...]") in the output is a failure: nothing '
+ "opened; fix the command.")
def _open_line(facts: Facts) -> str:
if facts.facts_source == "remote":
- return "show it with desktop_preview"
+ return f"show it with desktop_preview: {_PREVIEW_CALL}"
return f"open it in the default browser with {_OPEN.get(facts.os, '`xdg-open <file>`')}"
+def _shown_phrase(facts: Facts) -> str:
+ return "shown with desktop_preview" if facts.facts_source == "remote" else "opened in the default browser"
+
+
+def _page_lines(facts: Facts) -> list[str]:
+ """How a page reaches the user: a local backend opens it in their browser; a remote one cannot."""
+ if facts.facts_source == "remote":
+ return [f"Show a page with desktop_preview, through tool_call: {_PREVIEW_CALL}. Their browser is on "
+ "another computer.",
+ "Say the page is open only after desktop_preview returned success."]
+ check = f" {_CMD_BANNER}" if facts.os == "windows" else ""
+ return [f"Open a page in their default browser with {_OPEN.get(facts.os, '`xdg-open <file>`')}.",
+ f"Say the page is open only after the open command succeeded.{check}"]
+
+
def _task_prompt(option: str, label: str, facts: Facts, has_skill: Callable[[str], bool]) -> list[str]:
task = TASK_BY_ID.get(option, OWN_TASK)
picked = f'They picked "{label or task.label}". ' if (label or task.label) else ""
steps = [f"{n}. {step.replace('<open>', _open_line(facts))}" for n, step in enumerate(task.steps, 1)]
return [f"{picked}Your job: {task.goal}.",
f"Load these skills with skill_view first: {', '.join(task_skills(option, has_skill))}.",
- "Steps:", *steps, f"Output: {task.output}", f"Quality bar: {task.quality}", f"Done when: {task.done}"]
+ "Steps:", *steps, f"Output: {task.output.replace('<shown>', _shown_phrase(facts))}", f"Quality bar: {task.quality}", f"Done when: {task.done}"]
def _bullets(title: str, lines) -> str:
@@ -183,7 +204,7 @@ def build_guidance(option: str, facts: Facts, has_skill: Callable[[str], bool] =
label: str = "") -> str:
"""The prompt once a first task is picked; ``label`` is the card text they clicked, ``has_skill``
says whether a bundled skill is on this install."""
- work = [*_HOW_TO_WORK, *((_CONNECTORS,) if option in _CONNECTOR_TASKS else ())]
+ work = [*_HOW_TO_WORK, *_page_lines(facts), *((_CONNECTORS,) if option in _CONNECTOR_TASKS else ())]
host = [_OS_LINES.get(facts.os, _OS_LINES["linux"])]
if facts.os == "windows" and facts.arch == "arm64":
host.append(_ARM_WINDOWS)
diff --git a/tests/agent/test_onboarding_first_tasks.py b/tests/agent/test_onboarding_first_tasks.py
index 65475cc0baa..3c26654439f 100644
--- a/tests/agent/test_onboarding_first_tasks.py
+++ b/tests/agent/test_onboarding_first_tasks.py
@@ -78,11 +78,39 @@ def test_how_hermes_works_reads_the_docs_and_builds_three_screens():
@pytest.mark.parametrize(("facts", "opens"), [
- (MAC, "`open <file>`"), (PC, '`start "" <file>`'), (Facts(os="linux"), "`xdg-open <file>`"),
- (Facts(os="linux", facts_source="remote"), "show it with desktop_preview"),
+ (MAC, "`open <file>`"), (PC, '`cmd.exe /c start "" "<file>"`'), (Facts(os="linux"), "`xdg-open <file>`"),
])
-def test_how_hermes_works_opens_in_the_default_browser_unless_hermes_runs_elsewhere(facts, opens):
- assert opens in reminder("build_hermes", new_record(facts), facts)
+def test_a_local_backend_opens_the_page_in_the_default_browser_and_never_names_desktop_preview(facts, opens):
+ text = reminder("build_hermes", new_record(facts), facts)
+ site = reminder("build_site", new_record(facts), facts)
+
+ assert f"open it in the default browser with {opens}" in text
+ assert f"Open a page in their default browser with {opens}" in text
+ assert "Say the page is open only after the open command succeeded." in text
+ assert "desktop_preview" not in text and "desktop_preview" not in site
+ assert "opened in the default browser" in site
+
+
+def test_windows_opens_with_a_single_slash_cmd_and_a_banner_is_not_success():
+ """Vesper run 1: Git's `start` wrapper passes a literal `//c` under MSYS_NO_PATHCONV=1, cmd printed its
+ banner, exited 0 and nothing opened; the model still said the page was open."""
+ text = reminder("build_hermes", new_record(PC), PC)
+
+ assert '`start "" <file>`' not in text and "//c" not in text
+ assert "full Windows path (C:/Users/...)" in text
+ assert 'cmd banner ("Microsoft Windows [Version ...]") in the output is a failure' in text
+ assert "cmd banner" not in reminder("build_hermes", new_record(MAC), MAC)
+
+
+def test_a_remote_backend_shows_the_page_with_desktop_preview_through_tool_call():
+ facts = Facts(os="linux", facts_source="remote")
+ text = reminder("build_hermes", new_record(facts), facts)
+ call = 'tool_call {"calls":[{"name":"desktop_preview","arguments":{"action":"open","url":"<file>"}}]}'
+
+ assert f"show it with desktop_preview: {call}" in text
+ assert "Say the page is open only after desktop_preview returned success." in text
+ assert "default browser" not in text and "xdg-open" not in text
+ assert "shown with desktop_preview" in reminder("build_site", new_record(facts), facts)
def test_the_app_tasks_carry_the_connectors_playbook_and_the_menu_lists_only_eligible_rows():