[Bug]: Docker conversation workspace ignores mounted AGENTFLOW_RUNTIME_CLI_DIR and reinstalls on-demand npm CLIs
Component / host
Platform — runner / sandbox
Edition
Platform
LoopForge version
v0.4.3 (ghcr.io/tencent/loopforge:0.4.3), verified still present on main (96ed7da4)
What happened?
In a Docker Compose deployment using an on-demand npm agent CLI (such as opencode, claude-code, kimi, or pi):
- The platform already installs and caches the CLI under
$AGENTFLOW_RUNTIME_CLI_DIR(OnDemandCLIPath(provider)), anddockerSandboxalready bind-mountsRuntimeCLIDir()read-only at the exact same path inside every Docker sandbox container (internal/runtime/sandbox_docker.go:1139-1144). - LOOP nodes reuse that mounted CLI immediately (
sandbox_docker.go:467-486), and native conversation workspaces also reuseOnDemandCLIPath(provider)(internal/runtime/conversation_sandbox.go:150-152). - However, when entering a Docker conversation workspace,
ensureDockerCLI(internal/runtime/conversation_sandbox.go:221-240) only probesdockerCLISharedPath(/opt/loopforge/conversation-cli/bin) +toolchainPathSetup, and when missing only checks a shared host copy forAgentCLICursor(L230-239). It does not check the already-mountedOnDemandCLIPath(provider)for npm-installed CLIs (opencode,claude-code,kimi,pi).
Actual behavior:
Every new Docker conversation sandbox container triggers a full npm install --prefix /opt/loopforge/conversation-cli <pkg> from scratch (for opencode-ai this downloads >100 MB per container), stalling the first chat turn in workspace mode for several minutes (or timing out on slower networks), even though the exact same Linux binary is already bind-mounted read-only inside the container under $AGENTFLOW_RUNTIME_CLI_DIR.
Expected behavior:
Just like the existing AgentCLICursor branch in ensureDockerCLI (conversation_sandbox.go:230-239), when the CLI is not already on the container's PATH, ensureDockerCLI should check OnDemandCLIPath(provider) on Linux, probe it inside the container via s.probeCLIVersion(ctx, provider, shared) (to ensure architecture/libc compatibility and execute permission for the task user), and reuse it (installMode = "reuse") instead of re-downloading via npm install.
Reproduction
- Deploy LoopForge with Docker Compose (
ghcr.io/tencent/loopforge:0.4.3) whereAGENTFLOW_RUNTIME_CLI_DIRis set to${LOOPFORGE_DATA_DIR}/cli. - Configure
opencode(orclaude-code/kimi/pi) credentials and pre-install the CLI viaPOST /api/assistant/cli-install(confirmingGET /api/assistant/cli-install?engine=opencodereturnsinstalled). - Run a LOOP node with
opencode→ observes instant startup reusing$AGENTFLOW_RUNTIME_CLI_DIR/opencode/current/node_modules/.bin/opencode. - Open a chat session using
opencodeand enter a Docker conversation workspace (or attach to an existing LOOP workspace). - Observe
docker exec ... npm install --no-audit --no-fund --prefix /opt/loopforge/conversation-cli 'opencode-ai'running inside the container even though$AGENTFLOW_RUNTIME_CLI_DIRis already bind-mounted read-only inside that container.
Sanitized diagnostics
# Container mounts already include the shared CLI directory read-only:
{"Type":"bind","Source":"<LOOPFORGE_DATA_DIR>/cli","Destination":"<LOOPFORGE_DATA_DIR>/cli","RW":false}
# Yet ensureDockerCLI still executes a fresh npm install inside the container:
docker exec --user 0:0 --workdir / agentflow-run-<id> sh -lc ... \
npm install --no-audit --no-fund --prefix /opt/loopforge/conversation-cli 'opencode-ai'
Relevant code references (main @ 96ed7da4):
internal/runtime/sandbox_docker.go:467-486(onDemandCLIPathfor LOOP runs)internal/runtime/sandbox_docker.go:1139-1144(mountsRuntimeCLIDir()read-only into Docker containers)internal/runtime/conversation_sandbox.go:150-152(resolveNativeConversationBinaryusesOnDemandCLIPath)internal/runtime/conversation_sandbox.go:221-240(ensureDockerCLIonly reuses shared host copy forAgentCLICursor)
Safety checks
- [x] I removed credentials, private endpoints, internal identifiers, and personal data.
- [x] I searched existing issues for duplicates. (Checked #892, #957, #988 — those cover earlier v0.3.8 platform-mode installation/detection, not Docker conversation workspace reuse of mounted
AGENTFLOW_RUNTIME_CLI_DIR.)
If this is accepted, I'd be happy to submit a scoped PR with regression tests extending the probeCLIVersion reuse path in ensureDockerCLI to on-demand npm CLIs.
Thank you for the report. We understand that a Docker conversation workspace runs a fresh npm install for on-demand CLIs such as opencode, even when that CLI is already mounted read-only from AGENTFLOW_RUNTIME_CLI_DIR, which delays or times out the first turn.
This has been noted and will be reviewed with the current issue queue.