Skip to content

agmsgd is reported as stopped inside the Codex Linux sandbox (separate PID namespace) #1777

Open

Description

@joelmitz

Summary

Inside the Codex CLI Linux sandbox, agmsg reports a running agmsgd as stopped:

agmsgd (Codex notices) is stopped while enabled (reason: executor missing or boot/start evidence does not match (executor unavailable)). Run agmsg daemon start (recommended), ...

agmsgd is in fact running and delivering. The Codex sandbox runs commands in a separate PID namespace, so the executor PID recorded in install.db is not visible from inside it, and agmsg_daemon_read_state reads "not visible" as "dead".

Environment

  • agmsg 1.6.1 (a5339b4f); scripts/lib/daemon-state.sh is unchanged on current main
  • Linux 7.0.0, agmsgd running as a systemd user service
  • codex-cli 0.163.0, sandbox_mode = workspace-write (agmsg db/ teams/ run/ ext-tools/ in writable_roots, network_access = false)

Reproduction

With agmsgd running on the host (executor PID 615065 in this example):

# host
readlink /proc/self/ns/pid        # pid:[4026531836]
test -e /proc/615065 && echo visible   # visible

# inside the Codex sandbox (same result with -P :read-only)
codex sandbox -P :workspace -C <project> -- bash -c \
  'readlink /proc/self/ns/pid; test -e /proc/615065 && echo visible || echo "not visible"'
# pid:[4026532693]
# not visible

Any agmsg command that reaches agmsg_daemon_warn_if_stopped (e.g. identities.sh, inbox.sh via storage.sh:42) inside the sandbox prints the warning above. In the same session, a message sent to that Codex seat was accepted by agmsgd and answered about 20 seconds later, so delivery itself works.

Inside vs. outside the sandbox:

check host sandbox
processes visible 374 5
/proc/stat btime matches recorded boot matches recorded boot
/proc/<executor>/stat readable missing
kill -0 <executor> 0 ESRCH
install.db state ready / pid ready / pid (readable)
agmsg_daemon_read_state ready stopped

Where it goes wrong (scripts/lib/daemon-state.sh)

  1. L37: /proc/$pid/stat does not exist, so started_epoch stays empty.
  2. L103: _agmsg_pid_signal_presence returns gone. It already treats EPERM as alive (fix(liveness): a process you cannot signal is not a process that is gone #505), but a PID namespace returns ESRCH, which is indistinguishable from a dead process.
  3. L112: with started_epoch empty, the state becomes stopped with the reason above.

pidfile, socket existence and SQLite reads all succeed. Connecting to the agmsgd socket from inside the sandbox is refused (EPERM), so a socket-based liveness check would not help here either.

Impact

  • A false warning on agmsg commands run in the sandbox (rate-limited to once per 10 minutes), recommending agmsg daemon start, which is the wrong recovery.
  • run/agmsgd-warning-at is shared with the host, so a false warning from the sandbox also suppresses a genuine host-side warning for up to 10 minutes.
  • Delivery is not affected.

Possible fix

Minimal: on Linux, when /proc/<pid> is not visible and the caller's PID namespace is not the initial one (readlink /proc/self/ns/pid != pid:[4026531836], i.e. PROC_PID_INIT_INO), return unchecked instead of stopped. Ordinary commands already stay silent on unchecked, which removes both the false warning and the marker side effect. Trade-off: inside a container, a daemon that really died would also be unchecked.

More precise: have the executor record its own PID namespace in the daemon owner record at startup, and return unchecked only when the caller's namespace differs. This needs a schema change.

Related but different causes: #1631 (WSL2 btime drift), #505 (EPERM), #1690 (Git Bash).

Activity

  1. added 2 commits that reference this issue on Nov 2, 2026
    3ab51b1
    912d3a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions