Skip to content

Reuse the HTTP connection pool for remote plugin requests - #49100

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/3e929c34052798779a4f153e4db03b3f75b6f87d
Sep 28, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/3e929c34052798779a4f153e4db03b3f75b6f87d

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Reuse the HTTP connection pool for remote plugin requests

Why

Each call to PluginsConfigInput::remote_plugin_service_config created a new HTTP client pool, preventing connection reuse across service configurations.

What changed

Share one lazily initialized, route-aware pool across a PluginsConfigInput and its clones. Newly constructed inputs retain separate pools, while service configurations continue to use the current endpoint and product SKU and requests use the supplied authentication.

Testing

Add tests for lazy initialization, pool sharing across repeated calls and early clones, isolation between new inputs, and requests using updated endpoints, product SKUs, and authentication with the shared pool.

## Why

Each call to `PluginsConfigInput::remote_plugin_service_config` created a new HTTP client pool, preventing connection reuse across service configurations.

## What changed

Share one lazily initialized, route-aware pool across a `PluginsConfigInput` and its clones. Newly constructed inputs retain separate pools, while service configurations continue to use the current endpoint and product SKU and requests use the supplied authentication.

## Testing

Add tests for lazy initialization, pool sharing across repeated calls and early clones, isolation between new inputs, and requests using updated endpoints, product SKUs, and authentication with the shared pool.

GitOrigin-RevId: 3e929c34052798779a4f153e4db03b3f75b6f87d
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/3e929c34052798779a4f153e4db03b3f75b6f87d branch from cde1bfc to bfdb157 Compare September 28, 2026 23:33
@copyberry
copyberry Bot merged commit bfdb157 into main Sep 28, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/3e929c34052798779a4f153e4db03b3f75b6f87d branch September 28, 2026 23:33

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

Copy link
Copy Markdown
Contributor

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

chatgpt_base_url,
http_client_factory,
product_sku,
remote_http_clients: Arc::new(OnceLock::new()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain the pool across config-derived inputs

Config::plugins_config_input() calls PluginsConfigInput::new every time (codex-rs/core/src/config/mod.rs:1716-1725), and normal paths such as the app-server helper immediately call config.plugins_config_input().remote_plugin_service_config() (codex-rs/app-server/src/request_processors/plugins.rs:159-160). Initializing a fresh Arc<OnceLock<_>> here therefore creates a fresh pool for each ordinary remote-plugin operation; reuse occurs only when a caller happens to retain or clone one PluginsConfigInput. Keep the pool in configuration/session-level state (resetting it on a real config change) so sequential production requests can actually reuse connections.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 28, 2026

This branch was previously deployed

1 inactive deployment
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