Skip to content

fix(proxy): queue HTTP bridge gate waits - #892

Closed
Komzpa wants to merge 14 commits into
mainfrom
fix/http-bridge-admission-881
Closed

Komzpa wants to merge 14 commits into
mainfrom
fix/http-bridge-admission-881

Conversation

@Komzpa

@Komzpa Komzpa commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Consolidates the Responses HTTP bridge, stream-correctness, startup cleanup, and narrow compact response-shape fixes into one PR:

  • keep visible HTTP bridge requests queued after they claim a bridge queue slot instead of failing on the global response-create gate timeout
  • preserve bridge_queue_full as the bounded local overload response when the bridge queue itself is saturated
  • finalize unterminated raw HTTP Responses streams with stream_incomplete
  • preserve raw upstream Codex error SSE frames where the Codex route expects them, while keeping /v1/responses OpenAI SDK contract shaping intact
  • thread that raw-error contract through websocket fallback streams too
  • transfer API-key stream settlement ownership safely on caller cancellation, with fallback release if the background settlement fails or is cancelled
  • fail closed when a Responses follow-up has previous_response_id but the owning account cannot be resolved, before any account-scoped file affinity can reroute the continuation
  • settle timed-out startup probe tasks so probe exceptions do not leak as unhandled background task failures
  • normalize Codex-affinity standalone compact responses from remote-compaction-v2 into the single compact output item Codex clients expect, while leaving OpenAI-style /v1/responses/compact unchanged

This absorbs #894, #896, #877, #983, and #1013 so the bridge/proxy API contract lands as one reviewable PR.

Fixes #881.

Folded PRs

OpenSpec

  • openspec/changes/bound-http-bridge-gate-waits/
  • openspec/changes/finalize-unterminated-response-streams/
  • openspec/changes/preserve-http-stream-error-shape/
  • openspec/changes/fix-startup-probe-task-exceptions/
  • openspec/changes/bridge-codex-compaction-trigger/

Changes

  • Bound queued HTTP bridge gate waits without evicting requests that already claimed the bridge queue slot.
  • Require terminal SSE events before request logs/account health treat raw HTTP Responses streams as successful.
  • Normalize incomplete upstream streams into explicit response.failed events where required.
  • Preserve raw error frames for Codex-compatible routes and bridged raw-mode streams, including websocket fallback transport.
  • Make stream settlement/cancellation paths avoid double release and recover failed or cancelled background settlements.
  • Return a retryable continuity failure instead of switching accounts when previous-response ownership cannot be proven.
  • Apply the previous-response owner fail-closed gate before file-pin routing so an input_file.file_id on a different account cannot bypass owner lookup misses.
  • Preserve transient retry/failover when raw upstream EOF is converted into a pre-visible stream_incomplete event.
  • Cancel/settle timed-out startup probe tasks deterministically.
  • Normalize Codex remote-compaction-v2 output shape for /backend-api/codex/responses/compact.
  • Rebased onto current main and folded fix(proxy): settle timed-out startup probe tasks #983/Fix Codex Desktop remote compaction v2 output shape #1013.

Validation

git diff --check origin/main...HEAD
uv run openspec validate --specs
uv run ruff check app/modules/proxy/api.py app/modules/proxy/_service/http_bridge tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/integration/test_http_responses_bridge.py tests/integration/test_proxy_api_extended.py tests/integration/test_proxy_compact.py
uv run ty check app tests
uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_api_responses_contract.py tests/unit/test_db_session.py tests/unit/test_http_bridge_cancel_drain.py tests/integration/test_http_responses_bridge.py tests/integration/test_proxy_api_extended.py tests/integration/test_proxy_responses.py tests/integration/test_proxy_compact.py -q

Focused pytest result: 930 passed in 47.15s.

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

ℹ️ 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
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Komzpa
Komzpa force-pushed the fix/http-bridge-admission-881 branch from bef97bc to 52fbfae Compare June 3, 2026 08:45
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@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: 52fbfae594

ℹ️ 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
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

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

ℹ️ 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 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@codex review

@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 3, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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 added the 🤖 codex: ok [@codex review] says no issues found. label Jun 3, 2026
@Komzpa
Komzpa force-pushed the fix/http-bridge-admission-881 branch from 7d9a9d1 to 2a662e8 Compare June 3, 2026 19:46
@Soju06 Soju06 removed the 🤖 codex: ok [@codex review] says no issues found. label Jun 3, 2026
@Soju06

Soju06 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

@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: 2a662e8e87

ℹ️ 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
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 3, 2026
@Komzpa
Komzpa force-pushed the fix/http-bridge-admission-881 branch from 97ac1d1 to 4ec1cbb Compare June 3, 2026 21:25
@Komzpa

Komzpa commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ 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 added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: ok [@codex review] says no issues found. labels Jun 3, 2026
@Komzpa
Komzpa force-pushed the fix/http-bridge-admission-881 branch from 4ec1cbb to b99d260 Compare June 4, 2026 17:45
@Soju06

Soju06 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ 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 added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: ok [@codex review] says no issues found. labels Jun 11, 2026
@Komzpa
Komzpa force-pushed the fix/http-bridge-admission-881 branch from f82308a to a8134c1 Compare June 15, 2026 03:00
@Komzpa

Komzpa commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: a8134c152c

ℹ️ 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 added the 🤖 codex: ok [@codex review] says no issues found. label Jun 15, 2026
Komzpa and others added 14 commits June 16, 2026 02:42
Normalize the Codex-session compact JSON response so Desktop sees the single compaction output item it requires while leaving non-Codex compact responses unchanged.

Constraint: Codex Desktop remote compaction v2 requires exactly one compaction output item.

Rejected: Forwarding upstream compact output verbatim | Desktop counts legacy compaction_summary output as zero compaction items.

Confidence: high

Scope-risk: narrow

Directive: Keep compact response normalization scoped to Codex session affinity unless another client contract is verified.

Tested: python -m pytest tests/integration/test_proxy_compact.py tests/integration/test_http_responses_bridge.py -q (93 passed); python -m ruff check app/modules/proxy/api.py tests/integration/test_proxy_compact.py.

Not-tested: Full Docker Compose deployment; live upstream release compaction through GitHub issue reporter's environment.
(cherry picked from commit d83e7f7)
(cherry picked from commit 2b4b264)
@Komzpa

Komzpa commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

#892 has been folded into #875.

Carried scope: HTTP bridge admission/startup/stream-contract handling is now part of #875, including bridge queue gate waits, raw stream/error contract settlement, previous-response owner fail-closed routing, startup probe task cleanup from #983, and Codex-affinity compact v2 response-shape normalization from #1013.

Survivor: #875

@Komzpa Komzpa closed this Jun 15, 2026
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
)

## Summary
- Wire the existing per-account probe backend endpoint (`POST /api/accounts/{accountId}/probe`) into the Accounts dashboard.
- Add the frontend schema/client method, mutation, and MSW handler coverage for force-probe.
- Add a Force probe button to the account detail action surface while preserving the newer routing policy, Trusted Access, limit warm-up, and upstream proxy controls from current `main`.
- Refresh account list, account trends, per-account trend detail, and dashboard queries after a successful force-probe.
- Keep Force probe disabled for paused, deactivated, and re-auth-required accounts that the backend rejects.

## Stack relationship
- Remains separate from Soju06#892 because this is a dashboard/account-control feature, while Soju06#892 is the Responses HTTP bridge admission/stream contract bundle.
- Remains separate from Soju06#887 because this does not touch model catalog visibility or public model metadata.
- Does not absorb or supersede another open PR.

Closes Soju06#677

## Validation
- `uv run openspec validate add-account-probe-endpoint --strict`
- `cd frontend && bun run test src/features/accounts/components/account-actions.test.tsx src/features/accounts/components/account-detail.test.tsx src/features/accounts/hooks/use-accounts.test.ts src/features/accounts/schemas.test.ts src/test/mocks/handler-coverage.test.ts`
- `cd frontend && bun run test src/features/accounts/components/accounts-page.test.tsx`
- `cd frontend && bun run test:coverage`
- `cd frontend && bun run typecheck`
- `cd frontend && bun run lint`

Current head: `6aec65730b15f4a934db0daf6c3ed5e14a4d8fb4`
GitHub CI: pending on current head after the test-fixture fix push.
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.

bug: response_create_gate acquire-timeout drops streams under single-loop CPU starvation (needs backpressure/queue or multi-worker)

3 participants