Repository navigation
fix(lifecycle): readiness probe gates post-start injections (#406) - #419
Merged
Merged
Conversation
Docker reports a container as "running" several seconds before the in-container FastAPI server accepts connections. The existing credential-injection retry loop (3 attempts × 2s) exhausts before the server is listening under multi-agent deploys, resulting in a wall of ConnectError log lines and a batch of failed scheduled executions in the first 1–5 minutes after deploy. Add wait_for_agent_ready() polling GET /health at 1s intervals with a 60s default timeout. Gate it between container_start and the credential/skill/ read-only injection block in start_agent. On timeout, log warning and continue — existing retry logic remains as backstop. Configurable via AGENT_READINESS_TIMEOUT_S and AGENT_READINESS_POLL_INTERVAL_S env vars. Probe is best-effort: any exception during polling is swallowed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
dolho
force-pushed
the
fix/406-agent-readiness-probe
branch
from
April 21, 2026 07:30
b431815 to
8a9366c
Compare
vybe
approved these changes
Apr 21, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: closes startup race, non-blocking on failure. ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #406.
Docker reports a container as `running` several seconds before the in-container FastAPI server accepts connections. The existing credential-injection retry loop (3 × 2s = ~6s) exhausts before the agent server is listening under multi-agent deploys, producing a flood of `ConnectError` log lines and a batch of failed scheduled executions in the first 1–5 minutes after deploy.
Fix
Add `wait_for_agent_ready(agent_name, timeout_s, poll_interval_s)` in `services/agent_service/lifecycle.py`. Polls `GET http://agent-{name}:8000/health\` at 1s intervals with a 60s default timeout. Gated between `container_start` and the credential / skill / read-only injection block in `start_agent`.
Configurable via env:
Test plan
Out of scope (noted)
While verifying, observed an unrelated pre-existing bug in `inject_assigned_credentials`: the `if "not found" in str(e).lower():` check was intended to short-circuit the retry loop when `.credentials.enc` doesn't exist, but the actual error text is `"No .credentials.enc file found in agent workspace"` — no literal "not found" substring. Result: blank agents retry 3× unnecessarily. Not fixed here (different root cause, different ticket).
🤖 Generated with Claude Code