Skip to content

bug(upgrade): agents stay on the old base image after an upgrade and nothing says which ones — agent-side fixes are silently inert #4483

Closed

Description

@vybe

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:

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:latest and 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-version label 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_unreadable answer names a stale agent image and the restart when the agent's image predates the missing[] field, modelled on the Files surface's restart-required message.
  • docs/user-docs/guides/deploying/upgrading.md states that agents must be restarted to receive agent-side changes, and no longer says the base image needs rebuilding only when docker/base-image/Dockerfile changes (the image also bakes agent_server/, hooks/ and startup.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_matches is used by the cold-start path in src/backend/services/agent_service/lifecycle.py (recreate_reason = "image_drift").
  • The alert kind already exists for the system agent: base_image_stale in src/backend/services/platform_alerts.py, emitted from src/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/restart in src/backend/routers/ops.py.
  • The version label is written by scripts/deploy/build-base-image.sh and 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

  1. added
    priority-p1
    type-bug
    theme-reliability
    status-ready
    on Nov 12, 2026
  2. added
    status-in-progress
    and removed
    status-ready
    on Nov 15, 2026
  3. added
    status-in-dev
    and removed
    status-in-progress
    on Nov 16, 2026
  4. removed
    status-in-dev
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

priority-p1theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions