Skip to content

[codex] Assign response item IDs when recording history#28814

Merged
pakrym-oai merged 14 commits into
mainfrom
pakrym/response-item-ids-on-history
Jun 19, 2026
Merged

[codex] Assign response item IDs when recording history#28814
pakrym-oai merged 14 commits into
mainfrom
pakrym/response-item-ids-on-history

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Why

Client-created response items enter history without IDs, so their identity is lost across rollout persistence and resume. IDs should be assigned once at the history-recording boundary, while IDs returned by the server must remain unchanged.

The Responses API validates item IDs using type-specific prefixes. Locally generated IDs therefore use the matching prefix plus a hyphenated UUIDv7, keeping them valid while distinguishable from server-generated IDs. Because this changes persisted history and provider request shapes, the behavior is opt-in behind the under-development item_ids feature. Compaction triggers remain request controls whose API shape does not accept an ID.

What changed

  • Register the disabled-by-default item_ids feature and expose it in config.schema.json.
  • Make supported optional ResponseItem IDs serializable and expose them in the generated app-server schemas.
  • When item_ids is enabled, assign an ID during conversation-history preparation if an item has no ID.
  • Generate type-prefixed, hyphenated UUIDv7 IDs using the Responses API item conventions.
  • Preserve existing server IDs without rewriting them.
  • Persist assigned IDs in rollouts and include them in subsequent Responses requests.
  • Remove the unsupported ID field from CompactionTrigger and document why it has no ID.
  • Add integration coverage for enabled ID persistence, preservation of server IDs, and omission of generated IDs while the feature is disabled.

prepare_conversation_items_for_history is the single response-item ID allocation boundary.

Test plan

  • just test -p codex-features
  • just test -p codex-core response_item_ids_persist_across_resume_and_preserve_server_ids
  • just test -p codex-core non_openai_responses_requests_omit_item_turn_metadata
  • just test -p codex-core resize_all_images_prepares_failures_before_history_insertion
  • just test -p codex-protocol
  • just test -p codex-app-server-protocol
  • just test -p codex-api azure_default_store_attaches_ids_and_headers

Base automatically changed from pakrym/response-item-id-fields to main June 18, 2026 01:27
@pakrym-oai pakrym-oai force-pushed the pakrym/response-item-ids-on-history branch 3 times, most recently from 7acd80a to bd68179 Compare June 18, 2026 01:53
@pakrym-oai pakrym-oai marked this pull request as ready for review June 18, 2026 01:57
@pakrym-oai pakrym-oai requested a review from a team as a code owner June 18, 2026 01:57

@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: bd681791d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs Outdated
Comment thread codex-rs/protocol/src/models.rs
Comment thread codex-rs/protocol/src/models.rs
@pakrym-oai pakrym-oai force-pushed the pakrym/response-item-ids-on-history branch 2 times, most recently from 2cf87aa to 4966ca6 Compare June 18, 2026 02:30
@pakrym-oai pakrym-oai force-pushed the pakrym/response-item-ids-on-history branch from 4966ca6 to 009bd87 Compare June 18, 2026 04:21
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 009bd870cd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs
Comment thread codex-rs/protocol/src/models.rs
Comment thread codex-rs/core/src/session/mod.rs
ResponseItem::LocalShellCall { .. } => "lsh",
ResponseItem::FunctionCall { .. } => "fc",
ResponseItem::ToolSearchCall { .. } => "tsc",
ResponseItem::FunctionCallOutput { .. } => "fco",

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.

P1 Badge Use the Responses prefix for function output IDs

When item_ids is enabled and any function/tool result is recorded, this branch generates IDs like fco_<uuid> for function_call_output items. The Responses API uses the fc_... item-id shape for function tool call outputs and validates item IDs by type, so the next request after a tool call can be rejected solely because Codex minted an invalid output item ID; use the provider-accepted prefix here instead of the invented fco prefix.

Useful? React with 👍 / 👎.

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.

fco_ is fine.

@pakrym-oai pakrym-oai force-pushed the pakrym/response-item-ids-on-history branch from 6d33e10 to 009bd87 Compare June 18, 2026 16:27
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 949475bda2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +89 to +90
if !include_item_ids {
strip_response_item_ids(&mut body);

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.

P2 Badge Preserve Azure store item IDs by default

When using the Azure Responses endpoint, ModelClient::build_responses_request still sets store to true for every request, but include_item_ids is false unless the new under-development item_ids feature is enabled. This unconditional strip therefore removes IDs from the default Azure stored-history path; before this change the request.store && is_azure_responses_endpoint() branch specifically re-attached those IDs, so Azure continuation/store requests lose the item identifiers unless users opt into an unrelated rollout flag.

Useful? React with 👍 / 👎.

Comment thread codex-rs/core/src/session/mod.rs Outdated
Comment thread codex-rs/protocol/src/models.rs
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5233e4da7d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


/// Sets the Responses API item ID for variants that carry one.
pub fn set_id(&mut self, new_id: String) {
/// Sets or clears the Responses API item ID for variants that carry one.

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.

whats the point of ever stripping all the items on a request (by calling set_id None?)

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.

i guess it doesn't really matter though, the functionality is fine to have (and maybe some providers don't support the ID?)

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.

I want to re-enable this for everyone but we had it disabled for a bit (because having IDs cause Responses API to try and load the item).

@pakrym-oai pakrym-oai merged commit f00f93d into main Jun 19, 2026
45 of 47 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/response-item-ids-on-history branch June 19, 2026 00:30
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 19, 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