Skip to content

Keep the shared tunnel when a Codex stream is cancelled after its final event - #2

Merged
khairm merged 2 commits into
edgee-oauth-base-urlfrom
codex-complete-keeps-conn
Nov 6, 2026
Merged

khairm merged 2 commits into
edgee-oauth-base-urlfrom
codex-complete-keeps-conn

Conversation

@khairm

@khairm khairm commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Clients that stop reading at response.completed (e.g. the carehome-portal eval provider on oracle) cancel the request before end-of-stream. The round-7 silent-connection rule then retired a healthy conn, so oracle opened ~1 tunnel per request.

  • helps.MarkResponseComplete(body) sets a flag on the tracked uTLS response body (unwrapping the usage TTFT wrapper); finish() skips dropIfSilent when set.
  • Codex stream loop and Codex image stream reader call it on response.completed, response.incomplete, response.failed.
  • No timers.

Tests: TestUtlsClientKeepsTheTunnelWhenAStreamIsCancelledAfterItsFinalEvent (5 requests → 1 tunnel; 5 with the fix reverted). Round-7 silent-stream retire test still passes. go test -race -count=3 helps, Codex executor tests, vet, gofmt clean; go.mod/go.sum unchanged.

Live on ovh via switchboard + Pi: 2 accounts × 10 requests cancelled after reading: 20 tunnels without the mark, 2 with it.

🤖 Generated with Claude Code

Review follow-up (3681a31)

  • A terminal {"type":"error"} event now also marks the reply complete.
  • The image stream reader's mark is removed. Images use the standard transport, not the uTLS pool, so it did nothing.
  • New executor-level tests drive CodexExecutor.ExecuteStream through the uTLS pool, a chatgpt.com TLS server and a CONNECT proxy:
    • 5 streams cancelled at response.completed use 1 tunnel. With the mark removed they use 5.
    • An upstream that goes silent after response.created still has its tunnel retired, so 2 tunnels are opened.
  • helps.SetUtlsRootCAsForTest lets those tests trust the local server.
  • The release race gate now includes ./internal/runtime/executor.

…al event

A client that closes the stream right after response.completed cancelled the
request before end-of-stream, so the silent-connection rule retired a healthy
connection and every request opened a new tunnel. Codex readers now mark the
response complete on response.completed/incomplete/failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T16:10:36.852338Z a10b36d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…ough the pool

The image stream reader's mark is removed: images use the standard transport, so it was a no-op.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@khairm
khairm merged commit f15da5f into edgee-oauth-base-url Nov 6, 2026
3 checks passed
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