Repository navigation
fix(codex): a Codex session's hooks reach it even with Codex's shared daemon - #131
Merged
Merged
Conversation
… daemon Codex can run every session from one shared app-server daemon, and the daemon runs hooks with the environment of the session that started it. So with two Codex sessions on a box, every hook (prompt, tools, Stop, notify) reported the first session's BERTH_SESSION: the second session's work showed on the first, which was even renamed after its prompt, and the second was only ever read off its screen. A session started with daemon_auto_start = false still joins a daemon something else started. berthd now starts an interactive Codex (a new session, or a handoff that resumes one) with --no-daemon when the installed Codex lists it in its --help, read once per binary. --no-daemon keeps it off a daemon even one that is already running. For a Codex that runs under a daemon anyway (a repo's own command, an older Codex), the ledger no longer takes a Codex hook's session name on trust: an event about a conversation another live session holds is that session's, and one from a folder other than the named session's goes by its folder. Two sessions in one folder still can't be told apart that way until one has held its conversation. Refs cosscom#8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V7UV6sY16AabsdHtcyxyjL
|
@Stener1 is attempting to deploy a commit to the seanbrydonio's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Refs #8: its shared-daemon part. (#71 fixed the
notifypart.)Reproduced on Codex 0.163.0
Four Codex sessions through Shipyard, in one scratch repo on a Linux box:
cx8-aBERTH_SESSION=cx8-acx8-bcx8-a:SessionStart, prompt, tool,Stopandnotify.cx8-awas even renamed aftercx8-b's prompt, and turn check judgedcx8-b's turn oncx8-acx8-cdaemon_auto_start = falsecx8-atoo: it joined the daemon that was already runningcx8-dcodex --no-daemoncx8-d, correct, with the daemon still runningcx8-bandcx8-cnever got a hook event of their own: they were read off their screens only, and their finished-turn reports had no reply or transcript, whilecx8-d's did. The daemon is Codex's own managed copy (~/.codex/packages/app-server-daemon/…), started by the first session with that session's environment.Change
--no-daemonfor an interactive Codex (codexdaemon.go).AgentCommandWith(new sessions) and handoff'scodex resumeadd it when the installed Codex lists it in its--help. That's read once per binary (path and mtime), so a Codex without the flag still starts. Claude and the other agents are untouched, and so are the structured driver and headless runs, which don't use the TUI.Turns.claimed, used byresolveandSessionOf). An event about a conversation (agent_session_id) another live session holds goes to that session. One from a folder other than the named session's goes by its folder, as an unnamed event does. This covers a Codex under a daemon anyway (a repo's own command, an older Codex). Two sessions in one folder still can't be told apart until one has held its conversation. Other agents are taken by name as before.Tests
TestACodexDaemonsHooksReachTheirOwnSessionreplays the repro's pattern. It fails with the guard turned off.TestAgentCommandsPassAModelAndAnEffortcovers the flag, with and without support, and not adding it twice.go vet ./...,go test -race ./internal/box/ ./internal/integrations/...pass. Checked against this box's real Codex 0.163.0, the preset's command iscodex --no-daemon 'hi'.🤖 Generated with Claude Code
https://claude.ai/code/session_01V7UV6sY16AabsdHtcyxyjL