Skip to content

templates: upgrade Yutori templates from n1.5 to n2 - #237

Open
dprevoznik wants to merge 2 commits into
mainfrom
hypeship/yutori-n2-templates
Open

templates: upgrade Yutori templates from n1.5 to n2#237
dprevoznik wants to merge 2 commits into
mainfrom
hypeship/yutori-n2-templates

Conversation

@dprevoznik

@dprevoznik dprevoznik commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Upgrades the TypeScript and Python Yutori templates from Navigator n1.5 to n2.

n2 is a computer-use model where n1.5 was a browser-use model, so this is more than a model id swap — the tool surface, the action space, and the screenshot contract all changed. Adapter changes below.

What changed

Tool call shape. n1.5 returned one tool call per action. n2 returns a single computer_batch call carrying an ordered action list. The loop unpacks it, runs the actions in order, stops at the first error, and answers with one tool result carrying one screenshot taken after the last action that ran. Every coordinate in a batch refers to the pre-batch screenshot. This also cuts a screenshot round-trip per action.

disable_tools is now rejected (HTTP 400). The old templates used it to exclude the DOM/Playwright tools. n2 serves its tool set whole, so bash, read, write, and edit always reach the loop and have to be answered. New tools/system.{ts,py} backs them:

Tool Backed by
bash browsers.process.exec — working directory persists across calls, run_in_background detaches and reports pid + log path
read browsers.fs.readFilecat -n output with offset/limit paging
write browsers.fs.writeFile
edit read, exact-string replace, write — refuses to edit a file not read in this session

Removed actions. goto_url, go_back, go_forward, refresh, and horizontal scroll are gone; n2 drives the address bar and browser buttons itself. Added screenshot as a no-op batch member.

Kiosk mode removed. It hides the address bar n2 now depends on for navigation, and n2 explicitly wants a whole-screen capture — cropping chrome away removes click targets. Kernel's Computer Controls screenshot already captures the window with its chrome, which is what n2 wants, so the template just uses it directly. viewportWidth/Height are renamed to screenWidth/Height in the loop to reflect that they are the screen, not a page viewport.

Other adapter changes:

  • scroll amount is a wheel notch count, mapping 1:1 to Kernel's delta_y (previously multiplied by 4 for n1.5's ~10%-of-viewport unit).
  • mouse_down/mouse_up coordinates are optional — without them the button acts at the current cursor position, which is what a manual drag needs. Previously a missing coordinate silently fell back to screen center.
  • Key space gained punctuation word forms (slash, quote, backquote, …), mapped to XKeysym.
  • reasoning_content is echoed back on every turn; reasoning_effort is exposed as a payload field; max_completion_tokens raised 4096 → 16384 since the reasoning trace shares that budget.
  • temperature 0.3 → 0.6 (n2's server default; 0 is not recommended for a reasoning model).
  • Tool set pinned to computer_use_tools-20260825.
  • parallel_tool_calls is pinned true server-side, so a turn can carry several calls. The loop runs the first and answers the rest with an error telling the model to re-plan, since they were planned against a screenshot the first call already changed.
  • prev_request_id threads through so a trajectory groups into one conversation for usage reporting.
  • Screenshot trimming now mirrors n2's server-side retention (images kept only on the last 2 image-bearing messages) instead of the old size-triggered 6-screenshot window, with the 10 MB request cap as a backstop.

Testing

Both templates were run end-to-end against the live n2 API and a real Kernel browser:

  • Python — "Go to Hacker News and tell me the title of the top story." Completed in 5 iterations; navigated via the address bar, batched actions, returned the correct title.
  • TypeScript — "Go to example.com and tell me the exact heading text." Completed in 4 iterations, and the model independently reached for the new bash tool (curl -s https://example.com | cat -A), exercising the process.exec path on the browser VM.

Also unit-exercised against a fake Kernel client in both languages: batch ordering, stop-at-first-error with correct action attribution, coordinate denormalization and clamping, key expression parsing, bash working-directory persistence, edit-before-read guard, and screenshot trimming. tsc --noEmit and pyflakes are clean; go build ./... and go test ./pkg/... pass.

🤖 Generated with Claude Code


Note

Medium Risk
Large changes to reference agent loops and new VM shell/filesystem tooling on browser sessions, though scoped to sample templates rather than core platform services.

Overview
Upgrades the Python and TypeScript Yutori sample apps (and the create-template metadata) from Navigator n1.5 to n2, including default model n2, tool set computer_use_tools-20260825, and updated docs.

The agent loop is reworked for n2’s contract: GUI steps arrive as one computer_batch (run in order, stop on first error, one post-batch screenshot per result), bash / read / write / edit are handled via new SystemTools on Kernel process/filesystem APIs, and extra disable_tools / per-action navigation tools are dropped. Kiosk mode and the kiosk payload field are removed; reasoning_effort, prev_request_id, echoed reasoning_content, higher max_completion_tokens, and screenshot trimming aligned to n2’s last-two-image rule replace the old n1.5 behavior.

ComputerTool now batches actions, denormalizes coordinates internally, and no longer implements goto_url / history / refresh or horizontal scroll; viewport sizing is treated as screen dimensions with full-window captures.

Reviewed by Cursor Bugbot for commit cf32041. Bugbot is set up for automated code reviews on this repo. Configure here.

n2 is a computer-use model, not a browser-use model, so this is more than a
model id swap. The API surface changed in ways that break the n1.5 loop:

- GUI actions now arrive as a single `computer_batch` call carrying an action
  list instead of one tool call per action. The loop unpacks the batch, runs it
  in order, stops at the first error, and answers with one tool result and one
  screenshot taken after the last action that ran.
- `disable_tools` is rejected with a 400, so `bash`, `read`, `write`, and `edit`
  are always served. New system tool module backs them with Kernel's process and
  filesystem APIs.
- `goto_url`, `go_back`, `go_forward`, `refresh`, and horizontal scroll are gone
  — n2 drives the address bar and browser buttons directly. Kiosk mode is
  removed with them: it hides the address bar n2 needs, and n2 wants a
  whole-screen capture rather than a cropped one.
- `scroll` `amount` is now a wheel notch count, matching Kernel's delta_y 1:1.
- `mouse_down` / `mouse_up` take optional coordinates for manual drags.
- Key space gained punctuation word forms.
- `reasoning_content` is echoed back on each turn, `reasoning_effort` is exposed
  on the payload, and `max_completion_tokens` is raised to 16384 since the
  reasoning trace shares that budget.
- Screenshot trimming now matches n2's server-side retention: images are kept
  only on the last 2 image-bearing messages, with the 10 MB cap as a backstop.
- `prev_request_id` threads through so a trajectory groups into one conversation
  for usage reporting.

Verified end-to-end against the live n2 API and a Kernel browser in both
languages, including a `bash` call executed on the browser VM.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e2b3ba2. Configure here.

Comment thread pkg/templates/typescript/yutori/tools/system.ts Outdated
Comment thread pkg/templates/python/yutori/tools/system.py
String.prototype.replace with a string replacement expands $$, $&, $\` and $'
inside the model's new_string, corrupting shell and script edits. Use the
replacer function form. Python's str.replace has no such behavior.

Also pass cwd explicitly in the TypeScript bash tool so both adapters send the
same field; the Kernel API types it as nullable and accepts null.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant