Skip to content

feat(provision): propagate workspace model into runtime env (MVP hermes MiniMax flow) - #1685

Merged
HongmingWang-Rabbit merged 1 commit into
mainfrom
feat/propagate-model-env-to-provision
Apr 22, 2026
Merged

feat(provision): propagate workspace model into runtime env (MVP hermes MiniMax flow)#1685
HongmingWang-Rabbit merged 1 commit into
mainfrom
feat/propagate-model-env-to-provision

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Why

Customer creates a hermes workspace with `model=minimax/MiniMax-M2.7-highspeed` + secret `MINIMAX_API_KEY=sk-cp-…` in canvas → expects it to just work. Previously the model selection was dropped on the floor: `payload.Model` set the default in the workspace's `/configs/config.yaml` but didn't reach the runtime's installer, so template-hermes's `install.sh` (+ docker `start.sh`) seeded `~/.hermes/config.yaml` with the template default (nousresearch/hermes-4-70b) instead of MiniMax.

Fix

One helper, two call sites, no CP changes required:

`applyRuntimeModelEnv(envVars, runtime, model)` — runtime-switched helper. For hermes, sets `HERMES_DEFAULT_MODEL`. Other runtimes use their own config mechanism; the switch is empty for them.

Called in both:

  • `provisionWorkspaceOpts` (Docker path, local dev)
  • `provisionWorkspaceCP` (SaaS path, production)

The existing `envVars` map is already POSTed to CP as `{"env": ...}` and CP already `export`s each entry into workspace-EC2 user-data, so this change is fully contained to the tenant.

Pairs with

With all four merged, the end-to-end chain is:

```
Canvas Config tab (model + secret)
→ tenant workspace create handler
→ envVars populated from secrets + applyRuntimeModelEnv
→ CPProvisioner.Start POSTs to /cp/workspaces/provision
→ CP.ProvisionWorkspace bakes env into user-data
→ workspace EC2 boots, pip-installs, git-clones template
→ install.sh reads HERMES_DEFAULT_MODEL + MINIMAX_API_KEY from env
→ scripts/derive-provider.sh sets PROVIDER=minimax
→ ~/.hermes/config.yaml + .env seeded correctly
→ hermes gateway boots with MiniMax Token Plan as provider
→ molecule-runtime comes online
→ customer chats, MiniMax answers
```

Zero ops touch. Zero canvas-side Save-button dependency.

Design doc

Foundation for the broader WorkspaceBackend architecture tracked in `Molecule-AI/internal/product/designs/workspace-backends.md`. This PR is the last step-1 piece; steps 2-4 (formal interface, declarative manifest, first-new-backend) remain as follow-ups.

Test plan

  • `go build ./...` + `go vet ./...` clean in workspace-server
  • After deploy to staging/hongmingwang: create a hermes workspace with MiniMax-M2.7-highspeed + sk-cp-... secret, first chat succeeds without any ops intervention

🤖 Generated with Claude Code

Tenant's workspace provisioner now forwards payload.Model (set by
canvas Config tab when a user picks a model) through to the
workspace's runtime env as HERMES_DEFAULT_MODEL, so install.sh /
start.sh in the template can seed the right ~/.hermes/config.yaml
without any post-provision manual step.

Helper applyRuntimeModelEnv() is runtime-switched so each template
owns its own env contract — hermes uses HERMES_DEFAULT_MODEL, future
runtimes with different config schemas register their own cases.
Runtimes that read model from /configs/config.yaml instead (langgraph,
claude-code, deepagents) are unaffected: the switch has no case for
them, so this is a no-op in those paths.

Applied in both the Docker provisioner path (provisionWorkspaceOpts)
and the SaaS/CP path (provisionWorkspaceCP) so local dev and
production behave identically.

Combined with:
  - molecule-controlplane#231 (/opt/adapter/install.sh hook)
  - molecule-ai-workspace-template-hermes#8 (install.sh for bare-host)
  - molecule-ai-workspace-template-hermes#9 (derive-provider.sh)

this completes the MVP flow: customer creates a hermes workspace
in canvas with model = minimax/MiniMax-M2.7-highspeed + secret
MINIMAX_API_KEY = sk-cp-…, clicks Save, workspace provisions with
the MiniMax Token Plan hermes-agent gateway up and ready for the
first chat — no ops touch.

Foundation this builds on:
  - env injection works for every runtime
  - secret passthrough is generic (already via workspace_secrets)
  - per-runtime env-var contract encoded once (applyRuntimeModelEnv)
  - canvas Save button for later-edit remains a Files-API-over-EIC
    concern (tracked separately)

See internal/product/designs/workspace-backends.md for the broader
architectural direction this fits into.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit 2b60316 into main Apr 22, 2026
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the feat/propagate-model-env-to-provision branch April 24, 2026 00:09
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…queue (unblock Reno Stars cron starvation) (#1685)
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