Skip to content

fix: apply hosted-search history projection to native Lite compaction - #7268

Closed
EricFeng9 wants to merge 1 commit into
lidge-jun:devfrom
EricFeng9:codex/fix-lite-native-compaction
Closed

EricFeng9 wants to merge 1 commit into
lidge-jun:devfrom
EricFeng9:codex/fix-lite-native-compaction

Conversation

@EricFeng9

@EricFeng9 EricFeng9 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I ran into a repeatable remote-compaction failure after switching an existing conversation to the official Codex GPT-6.1 Sol route. A new conversation worked, but the existing conversation failed with an upstream 500 server_error during compaction.

I isolated the trigger to hosted-search history. With projectResponsesLiteHostedSearchHistory: true, ordinary Responses Lite turns already converted that history to reference notes, but the final adapter condition explicitly excluded _compactionRequest. Native v2 compaction therefore still sent the structural web_search_call items that reproduced the failure.

This PR removes that exclusion so native v2 compaction_trigger requests use the same existing opt-in projection. The canonical destination check, explicit Lite signal, default-off setting, bounded untrusted notes, and same-input reference handling stay in place. The native trigger, reasoning items, client tool call/result pairs, and native compaction output are preserved. Native v1 /responses/compact and portable/routed compaction retain their existing behavior.

I added regression coverage for the real trigger shape with both HTTP-header and WS-metadata Lite signals, and for the disabled setting. I also updated the configuration comments, architecture contract, and English/Simplified Chinese/Traditional Chinese documentation.

Related: #6742. This is scoped to native v2 Lite compaction with the existing option enabled. #7250's ordinary non-Lite missing-declaration report remains outside this PR.

Verification

The local check results below apply to the code in the current head, ca0a9ee3229d37477739eb08d0dc72712c489b5f. I have expanded the test references here without changing the branch or rerunning checks that had already passed.

What the focused tests cover

  • Native v2 request: the trigger case uses a real compaction_trigger input with both HTTP-header and WS-metadata Lite signals, with projection enabled and disabled. It checks that the trigger, reasoning item (including its opaque content), empty tool list, and client call/result pairs survive. Only the eligible hosted-search history is converted.
  • Native result: the handler case forwards one native v2 request, keeps its trigger and caller authentication, and returns the upstream native compaction content. This uses a mocked upstream response; it is not a native model run.
  • Referenced hosted items: the store:true case retains a hosted-search item referenced by an item_reference in the same input and converts only the other three search items. It also checks a second pass is unchanged. This existing test exercises an ordinary turn. Native v2 now reaches the same final projection block and referenced-ID exemption; I am not counting the ordinary-turn test as a separate native-trigger/reference test. The adjacent store:false case checks the existing reference-removal behavior.
  • Non-Lite and default-off: the protocol-signal cases leave unknown/non-Lite history structural, including when hosted declarations are missing. The native compaction control checks explicit Lite false wins over WS metadata true. The opt-in matrix requires literal boolean true; the configuration tests check that the option stays off in defaults and reject malformed values. The native trigger case above also covers the disabled option.
  • Ordinary continuation: the ordinary-turn cases preserve tools, tool choice, reasoning and client call/result items. The repeated-turn case keeps 190 client tool call/result pairs across three turns, and the idempotence case checks that notes are not converted again.
  • Other compaction paths: the portable/routed cases keep their existing summarizer behavior with the option on or off. The native v1 compact tests retain structural hosted history and native compact output; those response checks also use a mocked upstream.

Local commands and results

  • bun test tests/adapters/openai/openai-native-hosted-search-history.test.ts tests/responses/responses-native-compact-search-history.test.ts tests/responses/responses-compaction-override.test.ts tests/config/config-hosted-search-projection.test.ts: 147 passed, 0 failed (Bun 1.3.14). Before the source change, the updated regression tests had 3 failures.
  • ./node_modules/.bin/tsc --noEmit: passed.
  • bun scripts/structure-ssot.ts: passed.
  • bun scripts/privacy-scan.ts: passed.
  • node node_modules/astro/bin/astro.mjs build in docs-site/: passed; 577 pages built. Existing sshconfig syntax-highlighting warnings remained.
  • git diff --check: passed.

Earlier live reproduction

I also tested the change in my locally patched installed package through the official account route. One historical search item reproduced the failure before the fix; after the fix, native Lite compaction returned response.completed with a native compaction item. A separate compaction-only request using the affected conversation's reconstructed history also succeeded with 355,808 input tokens. I did not overwrite the original conversation history or include private payloads or credentials in this PR.

Those live checks used my patched local installation. I have not rerun live requests for this update; the test references above identify the automated coverage at ca0a9ee322.

Full-suite exception: I kept local validation to the affected adapter/configuration/compaction regressions given the size of the repository-wide suite and the scope of this one-condition change. I have not run the full suite or test:changed. The local Bun version was 1.3.14, not the repository-pinned test runner 1.4.3. Broader regression coverage and validation with that runner are still pending CI.

The current-head Cross-platform CI, Catalog async contracts, and React Doctor runs report action_required. I am not treating those runs, or the passing quality/bot checks, as functional CI passing.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features
    • When explicitly enabled, hosted-search history is now projected into notes for eligible native v2 Responses Lite compaction requests to the canonical ChatGPT Codex endpoint.
    • Other destinations and native v1 /responses/compact requests retain their existing behavior.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 270813bf-2f9a-47f4-bc3b-a3a61114f9f7
📥 Commits

Reviewing files that changed from the base of the PR and between 2a10a2b and ca0a9ee.

📒 Files selected for processing: 10
  • docs-site/src/content/docs/reference/configuration/providers.md
  • docs-site/src/content/docs/reference/proxy-formats.md
  • docs-site/src/content/docs/zh-cn/reference/configuration/providers.md
  • docs-site/src/content/docs/zh-cn/reference/proxy-formats.md
  • docs-site/src/content/docs/zh-tw/reference/configuration/providers.md
  • docs-site/src/content/docs/zh-tw/reference/proxy-formats.md
  • src/adapters/openai-responses/passthrough.ts
  • src/types/provider.ts
  • structure/providers-and-adapters.md
  • tests/adapters/openai/openai-native-hosted-search-history.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Hosted-search history projection now applies to eligible native v2 compaction_trigger requests as well as ordinary Responses Lite requests. The existing opt-in, destination, and Lite-intent conditions remain. Native v1 /responses/compact remains excluded.

Changes: Responses Lite hosted-search history

Layer / File(s) Summary
Projection scope and configuration
docs-site/src/content/docs/reference/configuration/providers.md:274, docs-site/src/content/docs/reference/proxy-formats.md:37, docs-site/src/content/docs/zh-cn/reference/configuration/providers.md:97, docs-site/src/content/docs/zh-cn/reference/proxy-formats.md:340, docs-site/src/content/docs/zh-tw/reference/configuration/providers.md:77, docs-site/src/content/docs/zh-tw/reference/proxy-formats.md:314, src/types/provider.ts:451-452, structure/providers-and-adapters.md:460
The documentation and provider option comment describe projection for eligible native v2 compaction requests and retain the existing conditions and exclusions.
Native compaction projection and tests
src/adapters/openai-responses/passthrough.ts:495-499, tests/adapters/openai/openai-native-hosted-search-history.test.ts:97-103, tests/adapters/openai/openai-native-hosted-search-history.test.ts:249-272
The adapter no longer excludes all compaction requests, while continuing to exclude portable compaction. Tests check projection behavior and preservation of compaction items.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ca0a9

The change extends the opted-in projection to eligible native v2 compaction while preserving native input items and existing v1 and portable compaction behavior. No merge blocker is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (7 skipped: 7 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: extending hosted-search history projection to native Lite compaction requests.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (7 skipped: 7 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (3/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 3/4).
  • The PR is more than 10 commits behind dev; the latest dev box has been unticked.
  • The checklist has been reset: re-test against the latest code and tick the boxes again.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

3/4 boxes ticked.

The PR is more than 10 commits behind dev; the latest dev box has been unticked.
The checklist has been reset: re-test against the latest code and tick the boxes again.
This PR stays in draft until every box above is ticked.

@Ingwannu

Copy link
Copy Markdown
Owner

Scoped review at ca0a9ee322: removing only the native-compaction exclusion extends the existing opt-in Lite projection while preserving the portable-compaction exclusion. Please keep native compaction trigger/result semantics, referenced hosted items, non-Lite/default-off and ordinary-continuation controls explicit in the receipt. This does not close #7250's generic ordinary non-Lite missing-declaration report; I linked that distinction there. Current head has quality/target/bot checks but no functional CI run in the rollup I inspected. Holding approval for head-bound adapter coverage; no native model/compaction call was executed.

Copy link
Copy Markdown
Contributor Author

Thanks @Ingwannu. I've expanded the Verification section for ca0a9ee322 and linked the tests for the native trigger/result, referenced hosted items, non-Lite/default-off behavior, ordinary continuation, and the unchanged portable/v1 paths. The branch is unchanged.

I also made the limits explicit: the native result handler test uses a mocked upstream, and the existing referenced-item test covers an ordinary turn through the shared projection block, not a separate native-trigger/reference case. The earlier live compaction checks were from my patched local installation; I haven't rerun live requests for this update. The 147 passing local tests used Bun 1.3.14, and the full suite and pinned 1.4.3 runner are still unverified.

I agree that #7250's ordinary non-Lite report is outside this fix and have stated that in the summary.

The current-head Cross-platform CI, Catalog async contracts, and React Doctor runs still show action_required. Could you approve the pending fork workflows so we can get functional CI results for this head?

@github-actions
github-actions Bot marked this pull request as draft October 18, 2026 15:53
@Ingwannu

Copy link
Copy Markdown
Owner

Thanks for separating the current-head mocked fixtures, predecessor live receipts and the Bun 1.3.14 limitation. The branch is unchanged, so I have not repeated the earlier review or counted the expanded prose as a new execution. The ordinary non-Lite report remains outside this fix.

I cannot approve the pending aggregate under the current maintenance execution scope: its gates job runs bun run privacy:scan, which needs renewed explicit authorization here. Those runs remain action_required rather than passed or failed functional evidence. Required CI and the pinned Bun 1.4.3 scope still need resolution; no waiver, new scan, workflow approval or live-install test was performed.

@lidge-jun

Copy link
Copy Markdown
Owner

Thank you @EricFeng9 for isolating this and for the careful regression coverage. Your commit is cherry-picked with authorship kept into #7353, which extends it. That PR also projects hosted-search history whenever the outbound request declares no search tool (#7250), so native v2 compaction with an empty tool list is covered even without the opt-in, and it fixes routed models losing search results on replay (#7269). The maintainer will close this PR when #7353 merges.

lidge-jun added a commit that referenced this pull request Oct 19, 2026
…) (#7353)

* fix: project hosted-search history during native Lite compaction

* fix(responses): project hosted-search history when no search tool is declared (#7250)

Native Sol answers a replayed web_search_call without a matching web_search declaration with a generic server_error. Project unreferenced cells into the existing bounded reference notes whenever the final body declares no hosted search, on every Responses destination; declared requests keep structural history. Also translates the comments carried over from #7268 into English.

* fix(web-search): replay sidecar search results to routed models (#7269)

Codex replays a hosted web_search_call cell without its result text, and the parser dropped it for routed providers, so a model whose turn ended on a client tool call forgot it had searched and repeated the search and the tool. Rebuild the cell as a web_search call/result pair when search is declared, and let the sidecar loops record the result under the emitted cell id so the next turn restores it, scoped to caller and conversation.

* fix(web-search): rebuild replayed searches at the input level and drop them without a sidecar

Review round 1: the parse-time pair could call an undeclared web_search tool when no sidecar plan resolves, split a parallel client batch, and collide with client call ids. Rewrite cells into function_call/output items before the item loop, defer the output past the following call batch, allocate collision-free call ids mapped back to cell ids, and remove the pairs when the search plan is undefined.

* fix(web-search): answer a replayed search before the next client batch

Review round 2: a deferred search output crossed into the following assistant turn when consecutive client batches followed the cell, and a restored failed search lost its error flag. Flush the deferred output when a call follows the batch outputs, and set the flag independently of the restored text.

---------

Co-authored-by: Junming Feng <12311031@mail.sustech.edu.cn>
@lidge-jun

Copy link
Copy Markdown
Owner

Thank you, @EricFeng9! Your native Lite compaction projection was absorbed into #7353 (merged into dev as 2339562), with credit to you there. Closing in favor of that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants