Repository navigation
Conversation
Signed-off-by: Afloat <ShuffleMonkey@163.com>
chrisknvidia
left a comment
There was a problem hiding this comment.
I reproduced the race on main with the PR's own tests: five simultaneous first calls built five OpenAI clients and five Anthropic clients, and the overlapping-completion test for Anthropic tripped it in 14 of 20 runs (two clients). At this head all six pass. The lock is only held around construction, a constructor failure leaves _client empty so the next call retries, the exceptions callers see are unchanged, the lock is per instance so two differently configured clients never share an SDK object, and the lock order (_client_lock then _provider_config_lock) is never reversed anywhere in the module. The inference, retry, rubric and embedding suites are the same between main and this head.
One not-blocking note inline on the retry-after-failure test, which passes on main too (the old code also left the cache empty when the constructor raised), so it guards against a stickier future fix rather than reproducing the bug.
Not blocking: EmbeddingClient in src/skillevaluator/embedding/client.py has the same unsynchronized lazy _client and _provider_config caches. It is out of scope here, but if it is ever called from the same worker pool it would want the same treatment.
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Summary
Tier 2 reviews up to five content clusters concurrently on one
LLMClient. Its lazy SDK cache was checked before SDK construction without synchronization. When first calls overlap, each worker constructs a separate OpenAI or Anthropic client and overwrites the cache, repeating connection-pool setup instead of sharing one client. A credential-free probe using the real OpenAI SDK and five simultaneous callers created and returned five distinct clients on the base revision.Protect only SDK initialization with a per-instance lock and check the cache again after acquiring it. Build and validate the client before publishing it, so a constructor failure leaves the cache empty and permits a later attempt. Completion requests run after the lock is released.
Verification
make lint,make test, andmake buildgates against commit6375935ecd99128fb37a32f5fb6b5195ad44184f: all passed. The full test result was 45,545 passed, 338 skipped, and 19 deselected; the skips and selection are the repository defaults.git diff --checkalso passed.Release Impact
CHANGELOG.md.