Skip to content

fix: seed task runtime home with the worker mise global config - #810

Merged
mrubens merged 1 commit into
developfrom
fix/seed-runtime-home-mise-config
Jul 27, 2026
Merged

fix: seed task runtime home with the worker mise global config#810
mrubens merged 1 commit into
developfrom
fix/seed-runtime-home-mise-config

Conversation

@mrubens

@mrubens mrubens commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Problem

Environment-defined stdio MCP servers (for example npx -y <mcp-package>) never came up in sandboxes. The config pipeline was fine — the servers reached the OpenCode config — but OpenCode marked them server unavailable / status=failed about a second after session create.

Root cause: npx/node in the sandbox are mise shims, and mise resolves tool versions from the global config at $HOME/.config/mise/config.toml when no repo-level mise config applies to the spawn cwd. The harness, agent bash, and MCP subprocesses all run with HOME remapped to the per-task runtime home (<workspace>/.roomote-runtime-home), which starts empty — worker setup's mise use -g nodejs@22 only writes the worker daemon's own home. So in any environment whose repo doesn't pin a node version, the shim fails instantly:

mise ERROR No version is set for shim: node

and the MCP server dies before it can speak MCP. The agent just silently never sees its tools.

Fix

Add seedRuntimeHomeMiseGlobalConfig, called at the HOME-remap point in runTask: it copies the worker home's .config/mise/config.toml into the task runtime home.

  • Never clobbers an existing runtime-home config (snapshot resume, or an agent that ran mise use -g itself).
  • Best-effort: a copy failure cannot break task startup.
  • File-based rather than env-var-based on purpose: MCP children are spawned with a minimal inherited env, so $HOME/.config is the one location that reaches every spawn path. This also fixes agent-bash npx in repos without a pinned node version.

Verification

  • Reproduced the failure in a live sandbox (env with a custom npx-based MCP server; OpenCode logged server unavailable key=<name> type=local status=failed, and running the command in agent bash showed the mise shim error).
  • With the fix, a fresh task in the same environment loaded the MCP server's tools and the agent successfully invoked them.
  • New unit tests for the seeding behavior (seed, no-clobber, missing source, same-home no-op). Full worker suite passes; lint:fast, check-types:fast, and knip pass.

Notes

  • Tests that vi.mock('../agent-home') needed the new export stubbed (missing mock exports crash the vitest fork via the run-task crash handler).
  • Follow-up (separate task): surface MCP startup failures as a diagnostic event / task-timeline warning instead of only OpenCode's internal log.

Environment-defined stdio MCP servers (e.g. npx-based) failed to start in
sandboxes because the task runtime HOME starts empty: mise shims resolve
tool versions from $HOME/.config/mise/config.toml, and worker setup only
writes the worker daemon's own home. OpenCode marked the servers
"server unavailable / status=failed" (mise: "No version is set for shim:
node") whenever no repo-level mise config applied to the spawn cwd.

Copy the worker home's global mise config into the runtime home at the
HOME-remap point in runTask. Existing runtime-home configs (snapshot
resume, agent-written) are left untouched, and seeding is best-effort so
it can never break task startup. This also fixes agent bash npx in repos
without a pinned node version.
@roomote-roomote

roomote-roomote Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

Reviewed c782868

@mrubens
mrubens merged commit 2a8cce0 into develop Jul 27, 2026
18 checks passed
@mrubens
mrubens deleted the fix/seed-runtime-home-mise-config branch July 27, 2026 04:45
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