Skip to content

feat: expose turn-start metadata to extensions#23688

Merged
jif-oai merged 3 commits into
mainfrom
jif/add-stuff-turn-lifecycle
May 20, 2026
Merged

feat: expose turn-start metadata to extensions#23688
jif-oai merged 3 commits into
mainfrom
jif/add-stuff-turn-lifecycle

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

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

Why

The goal extension needs more context when a turn starts than turn_store alone provides.

In particular, goal accounting needs the stable turn id, the effective collaboration mode, and the cumulative token-usage baseline captured at turn start so it can:

  • suppress goal accounting for plan-mode turns
  • compute exact per-turn deltas from cumulative total_token_usage snapshots instead of relying on the most recent usage event alone
  • keep the extension-owned accounting path aligned with the host turn lifecycle

What

  • extend codex_extension_api::TurnStartInput to expose turn_id, collaboration_mode, and token_usage_at_turn_start
  • pass the full TurnContext plus the captured token-usage baseline through the turn-start lifecycle emission path
  • initialize goal turn accounting from the turn-start baseline and collaboration mode
  • switch goal token accounting to compute deltas from cumulative total_token_usage snapshots
  • add coverage for the new turn-start lifecycle fields and for goal-accounting baseline behavior

Testing

  • added turn_start_lifecycle_exposes_turn_metadata_and_token_baseline in codex-rs/core/src/session/tests.rs
  • added ext/goal/tests/accounting.rs coverage for baseline-aware goal accounting and plan-mode suppression

@jif-oai jif-oai requested a review from a team as a code owner May 20, 2026 12:45
@jif-oai jif-oai changed the title feat: TLC feat: expose turn-start metadata to extensions May 20, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 20, 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: 5f3d8e5089

ℹ️ 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/turn_lifecycle.rs
@jif-oai jif-oai merged commit 59507b8 into main May 20, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/add-stuff-turn-lifecycle branch May 20, 2026 13:54
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 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