Skip to content

hooks: use new session IDs instead of thread IDs for hooks, apply parent's session ID to subagents' hooks#22268

Merged
eternal-openai merged 4 commits into
mainfrom
codex/hooks-session-id-rework
May 13, 2026
Merged

hooks: use new session IDs instead of thread IDs for hooks, apply parent's session ID to subagents' hooks#22268
eternal-openai merged 4 commits into
mainfrom
codex/hooks-session-id-rework

Conversation

@eternal-openai
Copy link
Copy Markdown
Contributor

@eternal-openai eternal-openai commented May 12, 2026

Why

hook semantics treat session_id as shared across a root session and its subagents. Codex hooks were still emitting the current thread ID, which made spawned agents look like independent sessions and made it harder for hook integrations to correlate work across a root thread and its spawned helpers

This change makes hooks use Codex's existing shared session identity so hook session_id matches the root-thread session across spawned subagents.

What Changed

  • switch hook payloads to use the existing shared session identity from core instead of the current thread ID
  • cover all hook surfaces that expose session_id, including SessionStart, tool hooks, compact hooks, prompt-submit hooks, stop hooks, and legacy after-agent dispatch

@eternal-openai eternal-openai requested a review from a team as a code owner May 12, 2026 06:51
@eternal-openai eternal-openai changed the title core: share hook session IDs across thread spawns core: use root hook session IDs for thread-spawn subagents May 12, 2026
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af3ff59c11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/session.rs Outdated
@eternal-openai eternal-openai force-pushed the codex/hooks-session-id-rework branch from af3ff59 to 11715c1 Compare May 12, 2026 07:02
@eternal-openai eternal-openai changed the title core: use root hook session IDs for thread-spawn subagents hooks: use new session IDs instead of thread IDs for hooks, apply parent's session ID to subagents' hooks May 12, 2026
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

I think of those things shouldn't be sessions but thread...

_ => format!("unsupported call: {tool_name}"),
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this will fail fmt

@eternal-openai eternal-openai merged commit fbfbfe5 into main May 13, 2026
27 checks passed
@eternal-openai eternal-openai deleted the codex/hooks-session-id-rework branch May 13, 2026 02:05
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants