Skip to content

Add agent binary pre-flight check and degraded pod diagnostics#47

Merged
cgwalters merged 3 commits into
cgwalters:mainfrom
arewm:detect-missing-binary
Apr 7, 2026
Merged

Add agent binary pre-flight check and degraded pod diagnostics#47
cgwalters merged 3 commits into
cgwalters:mainfrom
arewm:detect-missing-binary

Conversation

@arewm

@arewm arewm commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

When a devcontainer image lacks the agent binary (e.g. opencode), the
agent container exits with shell error 127 and the UI shows "agent down"
with no explanation.

This adds a three-layer diagnostic pipeline:

  • Startup script: command -v check before exec-ing the agent
    binary. If missing, exits with devaipod-specific code 42 and a
    structured error message to stderr. The binary name is parameterized
    via format string so the pattern works for any agent framework.

  • Backend: During pod cache refresh, exited/degraded agent containers
    are inspected via bollard. Exit code 42 populates a PodDiagnostics
    struct (code, message, suggestion) in the unified pod list response.

  • Frontend: Diagnostic banner on pod cards shows the error and
    suggests recreating with the dotfiles devcontainer or a different image.

Screenshot 2026-04-06 at 3 52 53 PM

arewm added 3 commits April 6, 2026 20:07
When a devcontainer image lacks the agent binary, the container
previously exited with a generic shell error 127.  Add a command -v
check before the exec so the startup script exits with
devaipod-specific code 42 and a structured stderr message instead.

The binary name is parameterized via the format string ({agent_binary})
so the same pattern works for any future agent framework.  Both the
primary agent and worker startup scripts include the check.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
Inspect exited agent containers during pod cache refresh to detect
known failure modes.  Exit code 42 (agent binary not found) populates
a new PodDiagnostics struct with a machine-readable code, message, and
recovery suggestion, surfaced in the /api/devaipod/pods response.

Container exit codes are also exposed via a new optional ExitCode field
on UnifiedContainerInfo for frontend visibility.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
Wire the new diagnostics field through to PodInfo and render a warning
banner with the error message and recovery suggestion when present.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
Comment thread src/web.rs

// Docker connection for inspecting exited agent containers (exit codes).
// This reuses the same socket but needs its own connection since the
// enrichment future consumed its one.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm but presumably we could avoid consuming it

@cgwalters cgwalters merged commit 4e717be into cgwalters:main Apr 7, 2026
3 checks passed
arewm added a commit to arewm/devaipod that referenced this pull request Apr 7, 2026
…n test

Address PR cgwalters#47 review feedback: create the bollard Docker connection
once before the enrichment future and reuse it for exit-code inspection,
rather than opening a redundant second connection afterward.

Add an integration test that exercises the full diagnostics pipeline by
creating a pod without mock-agent mode so the agent container hits the
pre-flight check (exit 42).  This required adding start_without_mock()
and create_pod_expect_degraded() to DevaipodHarness.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
arewm added a commit to arewm/devaipod that referenced this pull request Apr 14, 2026
…n test

Address PR cgwalters#47 review feedback: create the bollard Docker connection
once before the enrichment future and reuse it for exit-code inspection,
rather than opening a redundant second connection afterward.

Add an integration test that exercises the full diagnostics pipeline by
creating a pod without mock-agent mode so the agent container hits the
pre-flight check (exit 42).  This required adding start_without_mock()
and create_pod_expect_degraded() to DevaipodHarness.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: arewm <arewm@users.noreply.github.com>
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.

2 participants