Cache configured Faraday connections per client - #12
Merged
Merged
Conversation
Co-authored-by: Chris Hasiński <krzysztof.hasinski@gmail.com> Co-authored-by: Qlaw <noreply@qlaw.quick.shopify.io>
juharris
approved these changes
Aug 25, 2026
atesgoral
added a commit
that referenced
this pull request
Aug 25, 2026
* [x] Followed the guidelines in the [Contributing document](../blob/main/CONTRIBUTING.md) * [x] There is no other open pull request in this fork for the same change ## Summary - bump `ShopifAi::VERSION` from `9.0.0` to `9.1.0` - update the path-gem version in `Gemfile.lock` - release the connection-reuse changelog entry as `9.1.0` ## Reason for Change [PR #12](#12) adds backward-compatible connection lifecycle behavior: cached clients can now retain configured persistent Faraday adapters across requests. A minor version communicates that new capability more accurately than a patch release. Agent Server consumes this fork by Git tag. After this PR merges, the release will be completed with an annotated `v9.1.0` tag and GitHub Release. The fork will not be published to public RubyGems. ## Validation - `BUNDLE_FROZEN=true bundle _2.4.5_ exec rake` — 166 examples, 0 failures; 56 files, 0 RuboCop offenses - `git diff --check` --- *PR authored by Qlaw* Co-authored-by: Qlaw <noreply@qlaw.quick.shopify.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
betaandadminclients fresh connections and endpoint delegatesClient#inspectReason for Change
ShopifAi::Clientis cached by Agent Server, butShopifAi::HTTP#conncurrently creates a new Faraday connection and middleware stack for every API call. That means a configured persistent adapter cannot retain its socket pool across requests.This is the transport-policy-neutral foundation for shop/issues-sidekick#6707. It does not change the default Faraday adapter or add a dependency; a separate Agent Server PR can opt selected AI Proxy clients into
net_http_persistentwith bounded pool policy and rollout controls.The base connection-reuse pattern is adapted from alexrudall/ruby-openai#636, with concurrency, duplicated-helper, and inspect-safety hardening. alexrudall/ruby-openai#509 provides the persistent-adapter precedent.
Compatibility
net_httprequest behavior is unchanged apart from avoiding repeated connection-object and middleware-stack constructionbetaandadminduplicates remain isolated and cannot retain helpers bound to the original credentialsUsage's per-call admin-client lifetime is unchanged; Agent Server does not use that APIValidation
BUNDLE_FROZEN=true bundle _2.4.5_ exec rake— 166 examples, 0 failures; 56 files, 0 RuboCop offensesproxy.shopify.ai/pingproof withnet_http_persistent— 176.4 ms cold, then 22.0–31.9 ms warm across four repeated calls on the same cached connectionPR authored by Qlaw