Repository navigation
Description
Summary
After a platform upgrade, agents keep running on the old agent base image until each one is next started cold, and nothing tells the operator which agents those are. Only trinity-system raises a stale-image alert. Agent-side changes in the release are therefore silently inert on any agent that is never stopped. A second gap sits in front of that one: on update paths that do not rebuild the base image at all, no drift exists to detect, so every agent stays on the old runtime with no signal.
Context
Found in the v1.0.5 pre-release review (v1.0.0 → dev). Several changes in that range are enforced only by the new image, and a v1.0.0-image agent accepts the new backend's requests while ignoring them:
- The backend asks for auto-memory off on non-owner turns (bug: an agent can say "Saved" while the note goes to shared auto-memory, not write_user_memory #4156 / fix: spawn person-serving turns with Claude Code auto-memory off (#4156) #4172). An old-image agent drops the field and the turn reports success, so the cross-person exposure that fix closes stays open on that agent.
- Share-tier turn limits, the nested coding-agent CLI refusal and the vendor-telemetry opt-out live in the new image's hooks.
- On an old-image agent with no
.env, credential delivery in chat and the whole-file.envwriters answer409 env_unreadable, with a message that points at the.envfile when the remedy is a restart.
How the image reaches an install differs by update path, which is why this cannot be solved in one script:
| Update path | New base image arrives | Agents adopt it |
|---|---|---|
scripts/deploy/update.sh / trinity update (source) |
Rebuilt when docker/base-image changed |
Next cold start only |
scripts/deploy/start.sh --hosted |
Pulled and retagged every run | Next cold start only |
Manual git pull + docker compose build |
Only if the operator runs scripts/deploy/build-base-image.sh |
Next cold start only |
| Ops agent update on a source-built install | Not rebuilt | — |
The cold-start-only rule is deliberate (#1809): image drift must never turn a start of a running agent into a container kill. This issue does not change that rule. It makes the resulting state visible.
Acceptance Criteria
- After backend boot, the platform compares every running, non-ephemeral agent's image against the current
trinity-agent-base:latestand files one operator-queue alert naming the agents on an older image, with "restart the fleet" (or restart the named agents) as the next action. - The alert is one row per condition on the platform-alert seam: it updates as the set of stale agents changes and ends by itself when none are left. No row per agent, no row per boot.
- When the local base image's
trinity.base-image-versionlabel is older than the running backend's version, the alert says the base image itself needs rebuilding or re-pulling, and names the command for a source install and for a hosted install. - A base image with no version label, or a Docker read failure, is reported as "could not check", never as "up to date" and never as "stale".
- No running agent is recreated, restarted or stopped by this check. Ephemeral agents are excluded, as they are from the existing drift recreate.
- The check runs under a leader lease so multiple workers file one alert, and it does not block boot.
- The
409 env_unreadableanswer names a stale agent image and the restart when the agent's image predates themissing[]field, modelled on the Files surface's restart-required message. -
docs/user-docs/guides/deploying/upgrading.mdstates that agents must be restarted to receive agent-side changes, and no longer says the base image needs rebuilding only whendocker/base-image/Dockerfilechanges (the image also bakesagent_server/,hooks/andstartup.sh). - Unit tests cover: stale agents listed, alert cleared when none remain, label older than backend, label absent, Docker unreadable, ephemeral agent skipped.
Technical Notes
- The comparison already exists:
check_base_image_matchesis used by the cold-start path insrc/backend/services/agent_service/lifecycle.py(recreate_reason = "image_drift"). - The alert kind already exists for the system agent:
base_image_staleinsrc/backend/services/platform_alerts.py, emitted fromsrc/backend/services/system_agent_service.py. This extends the same condition to the fleet; reuse the seam, do not add a second mechanism. - The fleet restart route is
POST /api/ops/fleet/restartinsrc/backend/routers/ops.py. - The version label is written by
scripts/deploy/build-base-image.shand mirrored in.github/workflows/publish-images.yml. - Agent container state must be read through the tri-state
docker_service.agent_container_states(), so "no container" and "Docker unreadable" are not collapsed (bug: Workspace roster lists agents with no container (DB-sourced roster vs Docker-as-truth) #2196). - No schema change is expected. No MCP tool is needed; the alert reaches operators through the existing operator queue.
- Out of scope: auto-recreating agents, and changing the ops agent's update script to rebuild the base image (separate repository).
Activity
fix(upgrade): one alert names the running agents still on an old base…