Repository navigation
Conversation
After a short idle period, the first AI request could stall ~6.5 s on a pooled connection the network path had already dropped, then fail with -1005 before the retry succeeded. LLMClient now replaces its URLSession when no request has run for more than 45 s, so the next request opens a new connection instead of waiting for the dead one to time out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
FluidVoice PR build readyDownload FluidVoice-PR-1134-b2c2b6fa0e75 The artifact contains the ad-hoc-signed app ZIP, Xcode archive, build manifest, and installation instructions. It expires 5 days after the build. Install the app
This build has its own app identity, so its permissions are separate from the release version of FluidVoice. |
Description
After about 1.5–2 minutes idle, the first AI request can stall ~6.5 s on a pooled connection that the network path already dropped. It then fails with
-1005and the retry succeeds (#1016).LLMClientused oneURLSessionfor the whole app life, so it always tried the old connection first.Now
LLMClientreplaces itsURLSessionwhen no request has run for more than 45 s. The new session has an empty connection pool, so the next request opens a new connection (one extra TLS handshake) and does not wait for the dead one to time out. Requests closer together still share a connection. The reporter saw no stalls for requests less than ~60 s apart.finishTasksAndInvalidate().Type of Change
Related Issue or Discussion
Closes #1016
Testing
New regression tests:
LLMClientIdleConnectionTestsstarts a local keep-alive HTTP server that counts connections.testRequestAfterIdleGapOpensFreshConnection: two calls with an idle gap longer than the limit must use 2 connections. It fails without the fix (mainplus only the new init parameter: 1 connection, so the old one is reused) and passes with this change.testBackToBackRequestsReuseConnection: two calls in a row must still use 1 connection.Reproduction attempt: I could not reproduce the stall on my network. A probe with the same
URLSessionsetup sent requests toapi.groq.comafter idle gaps of 30–180 s, and every one finished in under 170 ms (HTTP/3, connection reused up to 150 s). So the dead connection depends on the network path (router, VPN or firewall). This PR makes the client stop reusing long-idle connections. @Conte777 offered to test, and their logs would confirm the fix on an affected network.Checks run:
LLMClientIdleConnectionTests,LLMClientRequestBodyTests,ModelTemperatureSupportTests,StripThinkingTagsTests: 43 tests, 0 failures.Full suite, with the same
xcodebuild testcommand as CI: 2,345 tests, 2,281 passed, 39 skipped, 25 failed. None of the failures are in code this PR changes:UpdateInstallationPipelineTestsfail withinvalidSignature(-67050). They fail the same way on unchangedmainon my Mac, probably because the local build is unsigned.AudioRouteRecoveryIntegrationTestsand 1AppSearchServiceTeststimed out in the full run. All of them pass when run alone on this branch.Tested on Intel Mac
Tested on Apple Silicon Mac
Tested on macOS version: 27.2 (26B5091g), arm64, FluidVoice 1.6.12-beta.1 (main @ 2ca292d)
Ran linter locally:
swiftlint --strict --config .swiftlint.yml Sources Tests Package.swift(0.63.2, 0 violations)Ran formatter locally:
swiftformat --config .swiftformaton the changed files (0.63.1, no changes needed). I did not run it on all ofSources, because this version wants to reformat many unrelated files.Ran tests locally: see above
Screenshots / Video
Regression test output, before and after:
Before (
mainplus the new test):After:
Notes
-1005without the 200 ms delay. It saves only 0.2 s.AI use: Claude drafted the change, the regression test and this description. I reviewed every changed line, ran the tests and the lint checks listed above, and ran the Groq probe. I could not reproduce the real stall on my network and did not test on Intel.
🤖 Generated with Claude Code