Skip to content

fix(proxy): trim durable full-resend continuations - #687

Merged
Soju06 merged 8 commits into
Soju06:mainfrom
Komzpa:fix/durable-http-bridge-full-resend-trim
May 18, 2026
Merged

Soju06 merged 8 commits into
Soju06:mainfrom
Komzpa:fix/durable-http-bridge-full-resend-trim

Conversation

@Komzpa

@Komzpa Komzpa commented May 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • persist completed HTTP bridge input-prefix metadata beside the durable latest response id
  • use that metadata to reattach a full resend only when its stored prefix fingerprint matches, then trim the resend down to the new tail
  • fail closed for same-websocket full resends while an earlier response is already visible, so clients do not see the answer restart as another upstream turn
  • close stale HTTP bridge sessions before returning a recovered previous_response_id session, so old upstream websocket state cannot leak after recovery
  • limit same-websocket full-resend rejection to codex-session replay-sized requests, avoiding false positives for normal fresh multi-item turns
  • mask responses/compact previous_response_not_found misses as public stream_incomplete, without penalizing the selected account or leaking raw resp_* ids
  • mask raw websocket previous_response_not_found terminal errors even when local pending state has lost the previous-response anchor, so clients receive the public stream_incomplete fail-closed event instead of a leaked resp_* id

Evidence

  • reported websocket continuity failures could surface raw upstream previous_response_not_found terminal errors repeatedly before a later turn recovered without previous_response_id
  • reported retries could resend a full response.create with previous_response_id=None after visible text had already started; codex-lb forwarded it as a fresh upstream turn
  • responses/compact continuity failures could surface upstream invalid_request_error / previous_response_id misses as raw public errors instead of the existing terminal stream_incomplete contract
  • .venv/bin/python -m pytest tests/unit/test_proxy_utils.py -k 'compact_previous_response_not_found or compact_responses_records_transient_error_for_generic_upstream_failure or stream_previous_response_not_found_proxy_error_is_masked_to_stream_incomplete'
  • .venv/bin/python -m pytest tests/integration/test_proxy_compact.py -k 'masks_previous_response_not_found or proxy_compact_success_preserves_compaction_payload'
  • .venv/bin/python -m pytest tests/unit/test_proxy_api_websocket_auth.py -k 'previous_response'
  • .venv/bin/python -m ruff check app/modules/proxy/service.py tests/unit/test_proxy_utils.py tests/integration/test_proxy_compact.py
  • .venv/bin/python -m pytest tests/unit/test_db_migrate.py::test_run_upgrade_auto_remaps_legacy_revision_ids tests/integration/test_migrations.py::test_run_startup_migrations_auto_remaps_legacy_alembic_revision_ids
  • .venv/bin/python -m ruff check app/db/alembic/versions/20260518_000000_add_http_bridge_durable_input_prefix.py
  • uv run pytest tests/unit/test_proxy_http_bridge.py::test_get_or_create_http_bridge_session_closes_stale_session_before_previous_response_recovery tests/unit/test_proxy_http_bridge.py::test_get_or_create_http_bridge_session_recovers_from_previous_response_id_mapping
  • uv run pytest tests/unit/test_proxy_utils.py::test_websocket_full_resend_conflicts_with_visible_pending tests/unit/test_proxy_utils.py::test_websocket_full_resend_allows_fresh_multi_item_request tests/unit/test_proxy_utils.py::test_websocket_full_resend_allows_explicit_previous_response_id tests/unit/test_proxy_http_bridge.py::test_get_or_create_http_bridge_session_closes_stale_session_before_previous_response_recovery
  • uvx ruff check app/modules/proxy/service.py tests/unit/test_proxy_http_bridge.py
  • uvx ruff format --check app/modules/proxy/service.py tests/unit/test_proxy_http_bridge.py
  • uv run pytest tests/unit/test_proxy_utils.py::test_process_upstream_websocket_text_masks_foreign_previous_response_not_found_for_only_created_followup tests/unit/test_proxy_utils.py::test_process_upstream_websocket_text_masks_anonymous_previous_response_not_found_for_created_followup tests/unit/test_proxy_utils.py::test_stream_previous_response_not_found_proxy_error_is_masked_to_stream_incomplete tests/unit/test_proxy_utils.py::test_stream_selection_budget_exhaustion_emits_timeout_event tests/unit/test_proxy_utils.py::test_stream_responses_budget_exhaustion_emits_timeout_event tests/unit/test_proxy_http_bridge.py::test_process_http_bridge_upstream_text_masks_single_previous_response_not_found tests/unit/test_proxy_http_bridge.py::test_process_http_bridge_upstream_text_masks_previous_response_not_found_when_anchor_was_lost
  • uv run pytest tests/unit (1693 passed, 39 skipped)
  • uvx ruff check app/modules/proxy/service.py tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py
  • uvx ruff format --check app/modules/proxy/service.py tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py
  • git diff --check
  • previous slice on this PR: HTTP bridge durable trim tests, bridge context blowup tests, durable bridge session tests, touched-file ruff, and sqlite migration check

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

Copy link
Copy Markdown

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: f46e2391b6

ℹ️ 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 app/modules/proxy/service.py Resolved
@Komzpa

Komzpa commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 600ccb6fb0

ℹ️ 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 app/modules/proxy/service.py Resolved
@Komzpa

Komzpa commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 4b88401d68

ℹ️ 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 app/modules/proxy/service.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label May 18, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label May 18, 2026
@Komzpa
Komzpa force-pushed the fix/durable-http-bridge-full-resend-trim branch from bd62782 to f270169 Compare May 18, 2026 01:40
@Komzpa

Komzpa commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: f270169cb5

ℹ️ 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 app/modules/proxy/service.py Resolved
@Komzpa Komzpa added 🤖 codex: needs work [@codex review] raised an issue 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue labels May 18, 2026
@Komzpa Komzpa removed the 🤖 codex: ok [@codex review] says no issues found. label May 18, 2026
@Komzpa

Komzpa commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

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

@Soju06
Soju06 merged commit dfc38c0 into Soju06:main May 18, 2026
18 checks passed
Soju06 added a commit that referenced this pull request May 19, 2026
## [1.18.2](v1.18.1...v1.18.2) (2026-05-19)


### Bug Fixes

* **api-keys:** map enforced service_tier auto/default to outbound omission ([#611](#611)) ([9a64e23](9a64e23))
* **api-keys:** size usage reservations from request budget ([#706](#706)) ([ea72eea](ea72eea))
* **dashboard:** derive quota status from usage windows ([#686](#686)) ([c463def](c463def))
* **dashboard:** make weekly credit pace backend-driven ([#692](#692)) ([313783c](313783c))
* **db:** recover stale reservations and serialize sqlite writers ([#667](#667)) ([6635628](6635628))
* **model-refresh:** refresh HTTP client on transport errors ([#547](#547)) ([2087df0](2087df0))
* **models:** report full context in v1 metadata ([#681](#681)) ([c3c977d](c3c977d))
* **proxy:** cap selector "Try again in" hint at 300s ([#690](#690)) ([cf09bd6](cf09bd6)), closes [#676](#676) [#678](#678)
* **proxy:** eliminate /v1 responses cancel/retry stream contamination ([#696](#696)) ([c9da497](c9da497))
* **proxy:** harden long Codex websocket turns ([#674](#674)) ([12bec0f](12bec0f))
* **proxy:** include sticky thread in budget-pressure guard ([#514](#514)) ([1e2c6d6](1e2c6d6))
* **proxy:** keep idle timeout classification after scheduler jitter ([#693](#693)) ([17e8abc](17e8abc))
* **proxy:** mask partial previous-response stream errors ([#689](#689)) ([a4a138c](a4a138c))
* **proxy:** persist request logs outside cancellation ([#688](#688)) ([6e8fa56](6e8fa56))
* **proxy:** repair interrupted Codex response continuity ([#698](#698)) ([682447f](682447f))
* **proxy:** trim durable full-resend continuations ([#687](#687)) ([dfc38c0](dfc38c0))
* **security:** remediate Docker code scanning alerts ([#699](#699)) ([de24c2e](de24c2e))


### Documentation

* add AnobleSCM as a contributor for code, and test ([#695](#695)) ([718931e](718931e))
* add jgorostegui as contributor ([#697](#697)) ([d9d5a6e](d9d5a6e))
* add linusmixson as contributor ([#705](#705)) ([f3ad60a](f3ad60a))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
* fix(proxy): trim durable full-resend continuations

* fix(proxy): mask compact previous-response misses

* fix(db): make durable bridge migration idempotent

* fix(proxy): close stale bridge sessions before recovery return

* fix(proxy): narrow websocket full-resend rejection

* fix(proxy): mask websocket previous response misses without local anchor

* fix(proxy): allow pre-visible websocket resend candidates

* style(proxy): format resend guard
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
## [1.18.2](Soju06/codex-lb@v1.18.1...v1.18.2) (2026-05-19)


### Bug Fixes

* **api-keys:** map enforced service_tier auto/default to outbound omission ([Soju06#611](Soju06#611)) ([ce0d1ea](Soju06@ce0d1ea))
* **api-keys:** size usage reservations from request budget ([Soju06#706](Soju06#706)) ([f3b1689](Soju06@f3b1689))
* **dashboard:** derive quota status from usage windows ([Soju06#686](Soju06#686)) ([acb4133](Soju06@acb4133))
* **dashboard:** make weekly credit pace backend-driven ([Soju06#692](Soju06#692)) ([383ccd4](Soju06@383ccd4))
* **db:** recover stale reservations and serialize sqlite writers ([Soju06#667](Soju06#667)) ([79dced5](Soju06@79dced5))
* **model-refresh:** refresh HTTP client on transport errors ([Soju06#547](Soju06#547)) ([f0b38a0](Soju06@f0b38a0))
* **models:** report full context in v1 metadata ([Soju06#681](Soju06#681)) ([82bd538](Soju06@82bd538))
* **proxy:** cap selector "Try again in" hint at 300s ([Soju06#690](Soju06#690)) ([1242bc1](Soju06@1242bc1)), closes [Soju06#676](Soju06#676) [Soju06#678](Soju06#678)
* **proxy:** eliminate /v1 responses cancel/retry stream contamination ([Soju06#696](Soju06#696)) ([d7f3cea](Soju06@d7f3cea))
* **proxy:** harden long Codex websocket turns ([Soju06#674](Soju06#674)) ([0828e63](Soju06@0828e63))
* **proxy:** include sticky thread in budget-pressure guard ([Soju06#514](Soju06#514)) ([e9d5b84](Soju06@e9d5b84))
* **proxy:** keep idle timeout classification after scheduler jitter ([Soju06#693](Soju06#693)) ([0860872](Soju06@0860872))
* **proxy:** mask partial previous-response stream errors ([Soju06#689](Soju06#689)) ([4563488](Soju06@4563488))
* **proxy:** persist request logs outside cancellation ([Soju06#688](Soju06#688)) ([684b1dc](Soju06@684b1dc))
* **proxy:** repair interrupted Codex response continuity ([Soju06#698](Soju06#698)) ([0e8232a](Soju06@0e8232a))
* **proxy:** trim durable full-resend continuations ([Soju06#687](Soju06#687)) ([e017bfc](Soju06@e017bfc))
* **security:** remediate Docker code scanning alerts ([Soju06#699](Soju06#699)) ([1b012f6](Soju06@1b012f6))


### Documentation

* add AnobleSCM as a contributor for code, and test ([Soju06#695](Soju06#695)) ([e95cfca](Soju06@e95cfca))
* add jgorostegui as contributor ([Soju06#697](Soju06#697)) ([4974c52](Soju06@4974c52))
* add linusmixson as contributor ([Soju06#705](Soju06#705)) ([ed41ae0](Soju06@ed41ae0))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants