Skip to content

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

Open
pakrym-oai wants to merge 1 commit into
mainfrom
pakrym/response-item-ids-on-history
Open

[codex] Assign response item IDs when recording history#28814
pakrym-oai wants to merge 1 commit 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 on lines +921 to 923
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
id: Option<String>,

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 Strip generated IDs for non-OpenAI providers

For configured Responses-compatible providers where provider.info().is_openai() is false, build_responses_request still only clears metadata, so these newly serializable IDs are sent on every recorded user/context/tool-output item. That changes the request shape for custom/non-OpenAI endpoints that previously received schema-only items and may reject arbitrary id fields; keep the locally generated IDs out of non-OpenAI provider requests just like the Codex metadata is stripped.

Useful? React with 👍 / 👎.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant