[Bug]: Runs waiting at an approval gate are blocked after the platform container is recreated (workspace bound to the old container hostname)
Component / host
Platform — deployment
Edition
Platform
LoopForge version
Observed on a Docker Compose deployment built from dd56585 (2026-11-15) plus local commits that do not touch the engine. The code paths cited below are unchanged on main at 451d38c.
What happened?
After the platform container is recreated (an upgrade, ./start.sh pull, or docker compose up after any change to the service), runs that were waiting at a human gate can no longer be approved. Approve returns the message below. Pass, reject, retry and resume carry the same check in the code, but I only exercised approve:
run <run-id> 的工作区绑定在 <old-container-id>:<data-dir>/workspaces,请在绑定实例上审批(或清理该 run 的 workspace 绑定后重试)
The run in question executes on a CLI runner, so its workspace is on the runner machine and was not affected by the recreate. The run stays blocked until someone edits runs.workspace_host in the database.
Cause, as far as I can trace it:
cmd/agentflow/main.go:143takes the workspace host fromos.Hostname()and nothing overrides it (AGENTFLOW_INSTANCE_IDonly changes the instance ID).compose.yamlsets nohostname:for theplatformservice, so the value is the container ID and changes on every recreate.- The run keeps the old value in
runs.workspace_host, soforeignWorkspaceBind(internal/engine/run_recovery.go:32) is true for the new container even though the workspace root is the same path. workspaceBlocked(internal/engine/run_recovery.go:39-48) normally lets a bind to a dead host be taken over, but its last line returnse.defaultExecutionRunner(r) != "". For a run bound to a runner this is always true, so the dead host is honoured forever and the checks ininternal/engine/run_ops.go(lines 147, 201, 278, 444, 702) reject every control action.
Expected: recreating the platform container should not strand runs whose workspace is on a runner or on the persistent data directory.
Not reproduced, from reading the code only: for a run that executes in the control-plane sandbox, the same hostname change makes the engine treat the workspace as lost and rebindWorkspaceHere (internal/engine/run_environment.go:298) discards the local checkout, although the files are still on the mounted data directory.
Reproduction
- Deploy with
docker compose --profile platform up -dand register a CLI runner. - Start a run that executes on the runner and has a manual approval node. Wait until it reaches the gate.
- Recreate the platform container. In my case it was
docker compose --profile platform up -dafter building a new image.--force-recreateshould have the same effect, but I did not run that variant. - Approve the gate in the UI or with
POST /api/runs/<run-id>/approve.
Result: HTTP 400 with the message above. SELECT workspace_host FROM runs WHERE id='<run-id>' shows the previous container ID, and docker exec <platform> hostname shows a different one.
Workaround that worked for me: set a fixed hostname: on the platform service in a Compose override, then update runs.workspace_host of the waiting runs to that name. Approval went through right after.
Sanitized diagnostics
Possible fixes, in the order I would try them:
- Set a stable
hostname:for theplatformservice incompose.yaml. One line, fixes single-instance Compose deployments. - Let the workspace host be configured (an environment variable next to
AGENTFLOW_INSTANCE_ID). - Revisit the last line of
workspaceBlockedfor runner-bound runs when the bound host has no live worker. I did not send a PR for this one because it changes a guard that protects unpushed workspace changes.
I can send a PR for the first item if that direction is acceptable.
Safety checks
- [x] I removed credentials, private endpoints, internal identifiers, and personal data.
- [x] I searched existing issues for duplicates.
Thanks for the report.
I understand this as: after the platform container is recreated, a run that was waiting at a human approval gate can no longer be approved, because its workspace binding still refers to the previous container hostname. The report already includes a version, reproduction steps, the observed error, and the expected behavior.
We've seen this issue and will review it along with the existing issue queue.
I’m working on the runner-owned workspace case: a dead platform hostname should not permanently block approval/control of a checkout that remains on the same runner. I reproduced the current guard failure and am adding regressions around the recovery path.
This slice will preserve live-owner/lease checks, runner reconnect and runner-switch protections, and the runner's files. It will not change the separate control-plane persistent-volume adoption behavior or Compose hostname configuration. The related workspace-loss/adoption predicates need to be handled together; simply removing the final guard would be unsafe.
Additional manifestation of the same host-binding change, from a Compose install upgraded to v0.4.1-rc.1 (one platform container, role=all):
After the upgrade recreated the platform container, opening the workspace terminal or the Agent browser on conversations created before the upgrade failed with:
浏览器所在执行端不可达:工作区控制通道配置错误:无法连接 Agent 浏览器;请为 API 和 Worker 配置相同的 AGENTFLOW_CONTROL_TOKEN
There is no API/worker split in this deployment, so AGENTFLOW_CONTROL_TOKEN is not configured and there is nothing to share — the hint is misleading. The old run still carries the previous container ID in runs.workspace_host, so foreignWorkspaceBind is true, WorkspaceRemoteHost sends the browser request down the control-channel path (internal/httpapi/browser.go → ForwardBrowserRequest), and the transport reports a configuration error.
Workaround that recovered it: pin the platform hostname and rebind the existing rows, for example
UPDATE runs SET workspace_host = 'loopforge-platform' WHERE workspace_host = '<previous-container-id>';
then restart. With the hostname pinned, later recreates keep the workspace reachable — I verified the Agent browser ensure path returns available: true instead of the control-channel error.
I have a PR up for the first item this issue suggests (a stable hostname: in compose.yaml plus a deployment note), so Compose recreates stop changing the workspace owner: https://github.com/Tencent/LoopForge/pull/1158. It does not touch the runner-bound recovery case being worked on above.
Separately, for the control-plane path it would help if a foreign bind to a dead local host were recoverable automatically (non-code conversation workspaces hold nothing that would be lost), or at least if the error named the stale workspace_host instead of AGENTFLOW_CONTROL_TOKEN.
补充一份 2026-11-25 升级后旧 SOP 恢复 的观察。与已有报告相同,本次不另开 Issue;也看到评论区已有 #1158 和 runner-owned recovery 的工作。
原流程已经完成开发、评审、测试和人工验收,停在发布处理。升级重建平台容器后,容器主机名变化影响旧工作区绑定;在本地 Compose 显式保留原平台 hostname 后,旧运行可以继续从发布节点重试,原需求/方案及上游节点结果保留。这里没有通过批量改写 runs 表来“恢复”。
恢复控制/重试以后,发布仍因 Git 凭据助手不可用退出128(相关 #1249),所以两类问题应独立诊断:
- 工作区归属/控制链路能否恢复;
- 恢复后的任务凭据与实际推送能否成功。
建议升级回归用一个真实待确认的旧运行覆盖:重建平台→恢复原工作区→保留上游产物与attempt历史→仅重跑目标节点→验证真实交付;同时保留活跃owner、lease、Runner切换保护,不以删除归属检查代替恢复。
以上是当日基于0.4.0后本地源码配套构建环境的记录,不是对当前最新版的重新复现;如已发布修复,希望给出适用版本和既有部署恢复步骤。