Skip to content

bug: cleanup sweep revokes a just-minted agent MCP key while the container is still starting #4259

Closed

Description

@vybe

Summary

The cleanup sweep revokes an agent's MCP key when the sweep runs between the key being minted and the agent's container becoming live, leaving a healthy agent without platform access.

Context

An agent was created and its MCP key minted; one second later the cleanup cycle logged [Cleanup] Deactivated 1 MCP key(s) belonging to agents that are no longer live (#1745); the container became ready seven seconds after that. The agent's first MCP call failed with 401 (chat_with_agent unavailable), and nothing repairs it afterwards. A second agent created minutes earlier, with no cleanup tick inside its start-up window, kept its key. On an instance that creates agents from a hook (onboarding), this is a coin flip per person.

Acceptance Criteria

  • A key whose agent row exists and is not soft-deleted is never treated as orphaned, whatever the container state (creating, starting, stopped).
  • Keys younger than a grace window (e.g. 10 minutes) are skipped by the sweep.
  • The sweep's log line names the agents whose keys it revoked, so an operator can see what happened.
  • A regression test creates an agent, runs the sweep during the start-up window, and asserts the key stays active.
  • Existing instances: a one-off check reactivates keys revoked while their agent row was live, or the release notes say how to find them.

Technical Notes

services.cleanup_service orphaned-key sweep (orphaned_agent_keys_revoked, #1745) versus services.agent_service.crud create path (key created before lifecycle reports the agent ready). Observed on a 1.0.0 dev build, 2026-11-04.

Activity

  1. added
    priority-p1
    type-bug
    theme-reliability
    status-ready
    on Nov 5, 2026
  2. added
    status-in-progress
    and removed
    status-ready
    on Nov 5, 2026
  3. self-assigned this
    on Nov 5, 2026
  4. added
    status-in-dev
    and removed
    status-in-progress
    on Nov 5, 2026
  5. 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

Assignees

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