fix(codex): discover a ws:// app-server in the SessionStart plug - #1057
Merged
fujibee merged 1 commit intoSep 12, 2026
Merged
Conversation
Discovery tried the AGMSG_CODEX_BRIDGE_APP_SERVER variable, a `unix://` token in the agent cmdline, and a `.sock` file. A ws:// (TCP) app-server matches none of them: codex-monitor.sh hands the URL to `codex --remote` and records the port in a `.port` file, so the plug hit `exit 0` before writing codex-bridge-request.<hash>. The launcher then kept using the stale request file and pinned every relaunch to a dead port. Fall back to _agmsg_codex_app_server_url, the helper _app-server.sh already provides for exactly this and codex-record-session.sh already uses.
fujibee
added a commit
that referenced
this pull request
Sep 13, 2026
#1056) (#1172) Adds coverage for the fourth app-server discovery fallback introduced in #1057: with AGMSG_CODEX_BRIDGE_APP_SERVER unset, no unix:// token on the agent cmdline, and no .sock file, the SessionStart plug still finds a ws:// app-server through its port file and writes the codex-bridge-request with that URL. Measured red on the commit immediately before #1057 landed on main and green from #1057 onward. Refs #1056.
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.
Fixes the first half of #1056.
_session-start.shlooks for the app-server in three places — theAGMSG_CODEX_BRIDGE_APP_SERVERvariable, aunix://token in the agent cmdline, and a.sockfile — and then gives up:A
ws://app-server matches none of them.codex-monitor.shhands the URL tocodex --remote(so there is nounix://token to scrape) and records the port inrun/codex-app-server.<hash>.port(so there is no socket file). The plug therefore exits before writingcodex-bridge-request.<hash>, the launcher keeps using whatever that file last held, and every relaunch is pinned to a dead port with no self-recovery. #1056 has the full symptom and log evidence.The port file does carry the URL, and
_app-server.sh:32already exports_agmsg_codex_app_server_url()to build it —codex-record-session.sh:115calls it for the same reason. This change just adds it as the last resort in the plug.SKILL_DIRandagmsg_sha1are both available in this context (the plug is sourced bysession-start.sh, see the header comment), and the helper returns empty rather than failing when it cannot resolve a port, so the existingexit 0still handles the genuine "no app-server" case.The second half of #1056 — the launcher trusting the request file without checking whether the endpoint is reachable — is a design judgment, so I left it out of this PR and described it in the issue instead.
Tests:
batswas not installed locally, so I ran it vianpx bats.tests/test_delivery.bats,tests/test_resume_seat_guard.bats,tests/test_close_fds.bats→ 200 passed, 0 failed.tests/test_codex_*.bats(bridge, bridge_launcher, monitor, resume, shim) → 142 passed, 0 failed. I did not run the whole suite locally.