Skip to content

fix(compute): replace print() with return in remote-compute-ssh JS examples - #2018

Merged
ewen-poch merged 1 commit into
aipoch:mainfrom
wen2zhou:fix/remote-compute-ssh-print-examples
Sep 1, 2026
Merged

fix(compute): replace print() with return in remote-compute-ssh JS examples#2018
ewen-poch merged 1 commit into
aipoch:mainfrom
wen2zhou:fix/remote-compute-ssh-print-examples

Conversation

@wen2zhou

@wen2zhou wen2zhou commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Agents writing Host SDK code in the notebook's JS kernel repeatedly produce ReferenceError: print is not defined after copying the remote-compute-ssh skill's JavaScript examples, which end cells with print(...).

The JS kernel (resources/notebook/repl_loop.js) defines no global print. Verified against the real kernel: print(help) throws ReferenceError, while return <expr> and a trailing expression both land the value in the cell's result (JSON-serialized). The trailing-expression form silently degrades to result: null with no error once a statement follows it, so explicit return is the reliable pattern to teach — and it matches the convention used throughout repl-loop.integration.test.ts.

The executable skill test injected a working print mock, so the examples passed in the test environment while failing in the real kernel.

Proposed change

  • resources/skills/remote-compute-ssh/SKILL.md: both JavaScript examples now end with return initial / return jobs instead of print(...); the "end the cell — no waiting, no loop" intent is unchanged.
  • src/main/compute/remote-compute-skill.test.ts: the injected print now throws exactly like the real kernel, so reintroducing print() into the doc fails the test the same way it fails in production; the test now asserts the return contract (the result snapshot becomes the cell's returned value).

Scope and non-goals

  • Only the two print() call sites in this skill's JS examples and the test that executes them. The Python-kernel skills' print() usage is legitimate and untouched.
  • No system-prompt or host.help changes; those surfaces contain no print references.

Acceptance criteria and validation

Ran after the last material edit:

  • npm test -- src/main/compute/remote-compute-skill.test.ts src/main/compute/skill-doc.test.ts src/main/compute/skill-provisioning.test.ts src/main/compute/compute-service.architecture.test.ts — 20 passed
  • npm run typecheck:node — pass
  • npx eslint src/main/compute/remote-compute-skill.test.ts — pass
  • Kernel behavior (print throws; return lands in result) exercised directly against resources/notebook/repl_loop.js

Review focus

Whether the executable-doc mock should model the kernel's missing print by throwing (chosen) versus dropping the print parameter entirely (a stray print() call would then surface as a plain ReferenceError).

…amples

The skill's JavaScript examples ended cells with print(), an API the JS
kernel does not define. Agents copying the pattern hit ReferenceError:
print is not defined. Use explicit return instead: it unconditionally
lands the value in the cell's result, while a trailing expression
silently degrades to result: null when its tail no longer parses.

The executable skill test used to inject a working print mock, which
masked the doc/kernel mismatch. The mock now throws like the real
kernel, and the test asserts the return contract instead.
@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026
@ewen-poch
ewen-poch merged commit 2ddb7cc into aipoch:main Sep 1, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants