Skip to content

core: share responses request builder with compact requests#20989

Merged
jif-oai merged 3 commits into
mainfrom
jif/request-helper
May 4, 2026
Merged

core: share responses request builder with compact requests#20989
jif-oai merged 3 commits into
mainfrom
jif/request-helper

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

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

Why

ModelClientSession and compact_conversation_history() were still rebuilding the same ResponsesApiRequest fields separately. That duplication makes it easy for normal /responses turns and compact requests to drift when request-shape changes land later, which is exactly the kind of cache-affecting divergence we want to avoid.

This follow-up keeps the scope small by extracting the shared request-construction logic into one helper and using it from both paths.

What changed

  • move ResponsesApiRequest construction into a shared ModelClient::build_responses_request(...) helper in core/src/client.rs
  • update the normal /responses streaming path to call that helper instead of the old ModelClientSession-local implementation
  • update compact_conversation_history() to derive its compact payload from the same helper so model, instructions, input, tools, parallel_tool_calls, reasoning, and text stay aligned with normal request building
  • add a unit test covering the shared helper's prompt cache key, installation metadata, and service_tier behavior

Verification

  • cargo test -p codex-core build_responses_request_sets_shared_cache_and_metadata_fields
  • cargo test -p codex-core --test all remote_compact_v2_reuses_context_compaction_for_followups

Docs

No docs update needed.

@jif-oai jif-oai requested a review from a team as a code owner May 4, 2026 12:26
@jif-oai jif-oai changed the title feat: request building helper core: share responses request builder with compact requests May 4, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 4, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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/core/src/client_tests.rs Outdated
@jif-oai jif-oai enabled auto-merge (squash) May 4, 2026 17:03
@jif-oai jif-oai merged commit e3451ce into main May 4, 2026
26 checks passed
@jif-oai jif-oai deleted the jif/request-helper branch May 4, 2026 17:18
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 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