Skip to content

extension-api: add TurnItemEmitter to tool calls#24813

Merged
sayan-oai merged 3 commits into
mainfrom
dev/sayan/extension-item-emitter
May 28, 2026
Merged

extension-api: add TurnItemEmitter to tool calls#24813
sayan-oai merged 3 commits into
mainfrom
dev/sayan/extension-item-emitter

Conversation

@sayan-oai

@sayan-oai sayan-oai commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Why

Extension-contributed tools need to emit visible turn items through Codex's normal event and persistence pipeline.

What

  • Add TurnItemEmitter to extension ToolCalls and route the core implementation through Session::emit_turn_item_*.
  • Hold weak session and turn references so retained tool calls cannot keep host state alive.
  • Provide a no-op emitter for extension test callers.

Test Plan

  • just test -p codex-core -E 'test(passes_turn_fields_and_scoped_turn_item_emitter_to_extension_call)'

@sayan-oai sayan-oai requested a review from a team as a code owner May 27, 2026 20:22
@sayan-oai sayan-oai changed the title add turnitememitter to extension api extension-api: add TurnItemEmitter to tool calls May 27, 2026
@sayan-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@sayan-oai sayan-oai closed this May 27, 2026
@sayan-oai sayan-oai reopened this May 27, 2026
@sayan-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

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

Copy link
Copy Markdown
Contributor

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: 1e770f71c0

ℹ️ 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/tools/src/tool_call.rs
let (Some(session), Some(turn)) = (self.session.upgrade(), self.turn.upgrade()) else {
return;
};
session.emit_turn_item_completed(turn.as_ref(), item).await;

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 is only using the low-level event emitter, so extension-emitted items skip the existing turn-item finalization path (TurnItemContributors plus host-owned handling like image-generation save/instruction wiring). Can we route this through one host-owned publish/finalize path, or narrow the API to item types that are already fully finalized by the extension?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch, ty.

narrowed api for now, left comment about future work to reuse core turnitem finalization

@sayan-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

@sayan-oai sayan-oai merged commit 2066874 into main May 28, 2026
31 checks passed
@sayan-oai sayan-oai deleted the dev/sayan/extension-item-emitter branch May 28, 2026 16:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 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.

2 participants