feat: add turn lifecycle contributors#22480
Merged
Merged
Conversation
Collaborator
Author
|
@codex review |
Contributor
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Why
Extensions can already contribute prompt, tool, turn-item, and thread-lifecycle behavior, but there was no explicit host-owned hook for per-turn setup and cleanup. That makes extension-private turn state awkward: an extension either has to stash it outside the turn lifecycle or depend on core runtime objects.
This adds a small turn lifecycle boundary. Extensions receive stable identifiers plus the existing session, thread, and turn
ExtensionDatastores, while core keeps owning task scheduling, cancellation, and turn teardown.What Changed
TurnLifecycleContributorwithon_turn_start,on_turn_stop, andon_turn_abortcallbacks incodex-rs/ext/extension-api.TurnStartInput,TurnStopInput, andTurnAbortInputpayloads that exposethread_id,turn_id,session_store,thread_store, andturn_store.ExtensionRegistryandExtensionRegistryBuilder.Sessionto emit turn start, stop, and abort callbacks from the existing turn/task lifecycle paths.ExtensionDatathroughRunningTaskandRemovedTaskso stop/abort callbacks receive the same turn store created at turn start.Verification