Skip to content

fix(lifecycle): skip credential/skill injection on idempotent start (#421) - #426

Merged
vybe merged 1 commit into
mainfrom
feature/421-skip-inject-running
Apr 20, 2026
Merged

vybe merged 1 commit into
mainfrom
feature/421-skip-inject-running

Conversation

@vybe

@vybe vybe commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Gate inject_assigned_credentials and inject_assigned_skills in start_agent_internal on was_already_running and not needs_recreation, eliminating the 3-retry-plus-ERROR storm that fired on health-check/start calls against busy, already-running containers.
  • Recreation paths (shared folders, auth env, resources, capabilities, guardrails) still inject — the container is effectively fresh.
  • When skipped, the response reports credentials_injection: "skipped" with reason: "container_already_running".

Changes

Test plan

  • pytest tests/unit/test_start_agent_skip_inject.py -v — 3/3 pass.
  • Full tests/unit/ sweep: 625 passed (11 pre-existing failures in test_file_upload.py are unrelated Telegram tests).
  • Manual: call MCP start_agent against a running container under load — verify no Credential import attempt warnings.
  • Manual: call /api/agents/{name}/start after stopping an agent — verify credentials still inject (log should show Imported N credential file(s) from .credentials.enc into {name}).
  • Manual: change use_platform_api_key and restart — verify recreation path still injects credentials on the fresh container.

Closes #421

Generated with Claude Code

…421)

`start_agent_internal` previously invoked `inject_assigned_credentials`
and `inject_assigned_skills` unconditionally after `container_start`,
even when the target was an already-running container that did not need
recreation. Under load, the HTTP injection call to the busy agent would
fail with `All connection attempts failed`, retry 3× (2s delay), and
log an ERROR — adding noise during exactly the moments the agent was
fragile.

The workspace volume preserves `.env` and `~/.claude/skills/` across
restarts, so the post-start HTTP injections on an idempotent start are
redundant. Recreation paths (shared folders, auth env vars, resource
limits, capabilities, guardrails) still trigger injection because the
container is effectively fresh.

Captures `was_already_running` after `container_reload` and gates both
injections on `was_already_running and not needs_recreation`. When
skipped, the result dict reports `status: "skipped"` with
`reason: "container_already_running"` so callers can distinguish.

Closes #421

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vybe
vybe merged commit 0027b8b into main Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: credential injection runs on health-check recovery path against already-running containers

1 participant