Skip to content

Make extension lifecycle hooks async#23291

Merged
jif-oai merged 3 commits into
mainfrom
jif/async-traits
May 18, 2026
Merged

Make extension lifecycle hooks async#23291
jif-oai merged 3 commits into
mainfrom
jif/async-traits

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 18, 2026

Why

Extension lifecycle hooks sit on the host/extension boundary, but the current trait surface only allows synchronous callbacks. That forces extensions that need to seed, rehydrate, observe, or flush extension-owned state during thread and turn transitions to either block inside the callback or move async work into separate host plumbing.

This PR makes those lifecycle callbacks awaitable so extension implementations can perform async work directly at the lifecycle point where the host already has the relevant session, thread, or turn stores available.

What changed

  • Makes ThreadLifecycleContributor and TurnLifecycleContributor async in codex-extension-api.
  • Awaits thread start/resume/stop and turn start/stop/abort lifecycle callbacks from codex-core.
  • Updates the guardian and memories extensions to implement the async lifecycle trait surface.
  • Updates the existing lifecycle tests to use async contributor implementations.
  • Adds async-trait to the crates that now expose or implement these async object-safe lifecycle traits.

Testing

  • Existing codex-core lifecycle tests were updated to cover async implementations for thread stop and turn abort ordering.

@jif-oai jif-oai requested a review from a team as a code owner May 18, 2026 11:27
@jif-oai jif-oai changed the title chore: async traits Make extension lifecycle hooks async May 18, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 18, 2026

@codex review

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: e5b9616788

ℹ️ 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/ext/extension-api/src/contributors.rs
Comment thread codex-rs/core/src/tasks/mod.rs
@jif-oai jif-oai merged commit 9531e93 into main May 18, 2026
29 of 30 checks passed
@jif-oai jif-oai deleted the jif/async-traits branch May 18, 2026 11:54
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 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.

1 participant