Repository navigation
fix: cap cold MCP schema workers at usable CPUs and deflake wall-clock unit tests - #45791
Conversation
…unit tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…n use Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Merging this PR will not alter performance
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…s deadlines Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…overy drain test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Automatic reviews are disabled for this repository. |
|
@litereview code-review |
✅ code-review5/5 · Ready for human reviewScope: full · Full PR review. No correctness findings. The one production change caps the cold MCP schema validation limiter at Checks and execution details
View review · Reviewed |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 58c6565. Configure here.
TLDR
Problem this solves:
How it solves it:
User Flow
Before: an MCP client on a one-CPU proxy pod calls a tool through the gateway's tool proxy and every call times out
--cpuset-cpuscontainer) with--num_workers 2and one MCP server configuredsearch_toolstools/callofcall_toolwith valid arguments on the freshly started proxy{"detail":"MCP handler did not respond in time"}after about 30s, and a second batch does the sameAfter: the same calls reach the MCP server and return its result
--cpuset-cpuscontainer) with--num_workers 2and one MCP server configuredsearch_toolstools/callofcall_toolwith valid arguments on the freshly started proxyMain went red (2026-10-15)
mcp-elicitationfailed onmainatf08840579ein https://github.com/BerriAI/litellm/actions/runs/38692812376. Attempt 1 (job 116282572497) failedtests/unit/proxy/_experimental/mcp_server/test_operations.py::test_discovery_concurrent_listings_drain_on_failure_and_cancellation[cancel]and the rerun (job 116287762627) failedtests/unit/proxy/_experimental/mcp_server/test_mcp_server_tool_calls_and_headers.py::test_truncated_jsonrpc_response_with_nested_method_skips_lock[False-é-1-result], both with aTimeoutErrorfrom a 1sasyncio.wait_for. The same job passed on the five previousmaincommits and the tip commit only touched cost calculation tests, so there is no culprit commit. Mechanism is the same hard 1s wall-clock deadline on in-process async work on a loaded runner that the nested-method lock fix below already coversThe discovery test now awaits the four listing events and the gateway task directly, keeping every assertion, and the CI pytest timeout still bounds a hang. With the production drain broken (sibling listings neither cancelled nor awaited) its
[failure]case fails at the closed-events assertion. Neither test reproduced locally (45 of 45 and 100 of 100), so the proof is this PR's ownmcp-elicitationrun at the tipEarlier flake evidence (2026-10-10 to 2026-10-14)
Flake evidence (run date 2026-10-14)
tests/unit/proxy/_experimental/mcp_server/test_mcp_server_tool_calls_and_headers.py::test_truncated_jsonrpc_response_with_nested_method_skips_lockflaked 4 times in the window, always acancel_request=Truecase in themcp-elicitationjob, failing on attempt 1 and passing on attempt 2 at the same sha in https://github.com/BerriAI/litellm/actions/runs/38464336690, https://github.com/BerriAI/litellm/actions/runs/38493778792, https://github.com/BerriAI/litellm/actions/runs/38524037967 and https://github.com/BerriAI/litellm/actions/runs/38524026698. Every failure was aTimeoutErrorfromasyncio.wait_for(request_in_handle.wait(), timeout=1.0), the wait for the first request POST to reach the fake handler, before the response POST under test was even sent. Mechanism is a hard 1s wall-clock deadline on in-process async work on a loaded runner. The fix waits on the event directly, and for the deadlock check it puts a recording lock into the session's lock slot (the server looks it up withsetdefault) and waits for whichever comes first, the response being handled or the response contending for the request's lock, then asserts it was the former. Replacing the top-levelmethodcheck with a flat substring check makes the fixed test fail on the contention assertion right away instead of after a timeout. Hang protection is left to the CI pytest timeout. The test also now clears the_stateful_session_auth_context_last_seenentry it createdtests/unit/proxy/spend_tracking/test_key_metadata_recovery.py::test_recover_key_metadata_from_spend_logs_retries_a_failed_query_only_after_the_miss_ttlflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38526405036, withassert (1791961913.553274 - 1791961882.199863) <= (30 + 1), and attempt 2 at the same sha passed. Mechanism is wall-clock dependence. The test compared the cache's real expiry timestamp with atime.time()taken before the call, with 1s of slack, so a slow runner broke it.InMemoryCachealready accepts aclock, so this test and its siblingtest_recover_key_metadata_from_spend_logs_never_caches_repeated_query_failures_as_long_as_a_hitnow build the cache with a fake clock, assert the miss expires exactly atnow + SPEND_LOG_KEY_METADATA_MISS_CACHE_TTL, and advance the clock past it instead of rewritingttl_dictby hand. They also assert how many times the spend log query ran. Dropping the short miss TTL in_remember_short_lived_missmakes both failtest_cold_concurrent_schema_validation_accepts_valid_argumentskept failing on attempt 1 onmain's unfixed copy in this window, which this PR already fixesNeither new candidate reproduced locally, the MCP test passing 400 of 400 including under 16 CPU busy loops, so both mechanisms come from the CI logs. After the fix each test passed 20 of 20 repeats and its owning file passed, and every test this PR already carried passed 20 of 20 on the combined branch
Dropped while merging main (2026-10-14)
#46261 landed equivalent fixes on
mainfortest_vertex_gemini_gcs_uri_mime.py::test_async_transform_request_body_offloads_extensionless_gs_not_plain_textand the generic API callback tests, so this PR now takesmain's version of both files and drops its own fixes there. It keepstest_generic_api_callback_sends_queued_events_on_its_own, becausemainalso flushes those tests by hand and has nothing else covering the automatic flush. The 2026-10-10 and 2026-10-12 sections below still describe the original flakesNot flakes in the 2026-10-14 window
On CircleCI,
tests/integration/messages_endpoint/providers/anthropic/test_anthropic_messages_pre_content_retry_wire.py::test_stream_failing_before_content_is_retried_on_the_same_group_and_completes[error_frame-429-request]failed twice withState did not converge: [], meaning no spend log row showed up for the retried request within 70s, in [REDACTED SECRET]/gh/BerriAI/litellm/2259644 and [REDACTED SECRET]/gh/BerriAI/litellm/2259479, and passed in neighboring integration workflows. The mechanism is not pinned, so this PR leaves it alone. The rest of the CircleCIintegrationfailures repeated across workflows and are breakages or rig issues, not flakes. On GitHub Actions the other red jobs were checkout timeouts, a CodeQL result set over its 2 GiB limit and a migrationlock_timeoutcheck, which are infra or real failuresFlake evidence (run date 2026-10-13)
tests/unit/proxy/_experimental/mcp_server/test_mcp_tool_search.py::test_cold_concurrent_schema_validation_accepts_valid_argumentsfailed in 72 workflow runs in the window, onmainand on many unrelated PR branches. Onmainit failed on attempt 1 and passed on attempt 2 at the same sha in https://github.com/BerriAI/litellm/actions/runs/38298557060 (e12bc629), https://github.com/BerriAI/litellm/actions/runs/38299209693 (19327a60) and https://github.com/BerriAI/litellm/actions/runs/38307417758 (fead47fa). It failed on both attempts of https://github.com/BerriAI/litellm/actions/runs/38350698434 (c3ca8a51). Every failure returned "Tool argument validation exceeded its time limit" for all eight calls after about 30.15s, and the passing attempts took 28.15s and 29.67s against the same 30s limitMechanism is CPU oversubscription during cold worker startup, which is a real product bug. The test pins the proxy to one CPU, the way a
--cpuset-cpuscontainer or a static CPU manager pod does, and fires eight valid validations._tool_argument_validation_erroralways allowed four process workers, so four cold workers each imported litellm on the same core and every call took about four imports' worth of CPU before validating anything. On a GitHub runner that lands right at the 30s validation deadline, so valid tool arguments got rejected. The fix sizes the validation limiter to the CPUs in the process affinity, capped at the old 4. On one CPU the first call pays one cold import and the other seven reuse the warm worker, and hosts with 4 or more CPUs keep 4 workers. The test also checks that no more than one worker was started while pinned. Hardcoding the limiter back to 4 makes it fail withassert 4 <= 1, and pinned to one CPU locally the call drops from 14.7s to 2.6stests/unit/integrations/langfuse/test_langfuse_sdk.py::test_cold_prompt_miss_never_sleeps_when_langfuse_is_down[http-500]flaked again onmain's unfixed copy in https://github.com/BerriAI/litellm/actions/runs/38228185072 (litellm_win_wheel_uv_python_4b8eat3c696ed5). This PR already carries its fix from 2026-10-10The fixed MCP test passed 20 of 20 repeats. Its owning file and the whole
mcp-servershard passed under-n 4 --dist loadscope, apart from 21test_semantic_tool_filter.pytests that need the optionalsemantic_routerpackage this box lacks. The seven tests this PR already carried passed 20 of 20 on the combined branch, with the whole Langfuse and generic API files each run 20 timesNot flakes in the 2026-10-13 window
Three unit tests timed out together at the 120s pytest limit in one job of https://github.com/BerriAI/litellm/actions/runs/38301603657 and passed on attempt 2, namely
test_poller_releases_budget_reservation_when_interaction_ends_without_usage,test_proxy_process_request_forwards_decoded_container_idandtest_pass_through_request_stream_param_override. All three hit the timeout at the same second, which points at a stalled runner rather than the tests, so they are left unfixed and unreproduced. Other unit failures followed what their branches changed and failed on every run of those branches, e.g. the OCI Cohere tests onfix/oci-cohere-tool-result-turnand the Anthropic error format tests onlitellm_messages_529_overloaded_error. The rest of the red jobs were lint, title, cost map guard and CodeQL checks on PR branches, which are not test flakesFlake evidence (run date 2026-10-12)
tests/unit/caching/test_request_redis_batch_pre_call.py::test_the_prefetch_mget_carries_only_the_keys_whose_read_is_dueflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38165618919 (litellm_fix_openapi_yamlat812a899f). The next run on that branch atf834cb74passed it in https://github.com/BerriAI/litellm/actions/runs/38167491546, and the only change in between was the MCP server manager. The second pipeline MGET carried extradep-a:anthropic/claude-x:rpm:18-55andtpmkeys. Mechanism is wall-clock dependence. The test pins the cache clock but the usage-based routing v2 rpm and tpm keys come fromget_utc_datetime()inlowest_tpm_rpm_v2, so a real minute rollover between the two requests made the second one read fresh minute keys. A scratch clock that rolls 12:00:59 to 12:01:00 between the two scopes reproduces the extra keys on unfixed code. The fix pinslowest_tpm_rpm_v2.get_utc_datetimethe same wayrouter_minute_pinneddoes. Setting the usage cache expiry to zero makes the fixed test fail with the extra keystests/unit/llms/vertex_ai/test_vertex_gemini_gcs_uri_mime.py::test_async_transform_request_body_offloads_extensionless_gs_not_plain_textflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38227361814 (feature/smtp-email-spend-reportsat4a08515c), withEvent loop blocked for 0.448s ... assert 0.448 < 0.4. The adjacent sha4987e9dcpassed in https://github.com/BerriAI/litellm/actions/runs/38224815634 and the diff between them only touched spend report email code. Mechanism is an assertion on elapsed wall-clock time, where a fake GCS call slept 0.5s and a concurrent 0.05s sleep had to finish under 0.4s. The fix uses two thread events. The fake GCS call signals it started and then waits for the event loop to set a second event, and the test asserts that wait succeeded. Making the transform call the GCS lookup synchronously makes the fixed test failtests/unit/proxy/roi_calculator/test_gitlab.py::test_fork_lookups_overlap_with_a_bounded_number_of_requestsflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38135356356 (litellm_any_sweep_20261011atb2bdd597), with aTimeoutErrorfromasyncio.wait_for(started.get(), timeout=1)on the first wave. The next sha8cf53e54passed in https://github.com/BerriAI/litellm/actions/runs/38136696998 and only changed OpenRouter and SageMaker code. Mechanism is a hard 1s wall-clock deadline on in-process async work on a loaded runner. The fix awaits the queue and the task directly and leaves hang protection to the CI pytest timeout. Raising the fork lookup semaphore from 8 to 9 makes the fixed test fail atstarted.empty(), and lowering it to 7 makes it hang until the pytest timeoutNone of these three failed in 20 local repeats except the Redis prefetch test, which failed once with an
IndexErroron a missing second pipeline rather than the CI key mismatch. That local failure did not recur in 20 repeats after the fix, but its mechanism is not confirmed to be the same minute rollover. After the fix each test passed 20 of 20 repeats and each owning file passed alone and under CPU burn. The five tests this PR already carried also passed 20 of 20 each on the combined branchNot flakes in the 2026-10-12 window
The other unit and smoke failures in the window failed on every run of their branch and followed what those branches changed, e.g.
test_unit_of_work.pyonfeat/team-token-budget, the vertex passthrough billing tests onfix/gemini-tool-use-tokens-billingand the prisma span tests on a forkmain. The rest were infra, namely checkout timeouts, a Rustmaturinbuild failure duringuv sync, an artifact upload timeout, and the scheduled E2E replay failing to resolve its fixtures bundle (unexpected end of JSON input)Flake evidence (run date 2026-10-11)
tests/unit/test_router/test_router_helper_utils.py::test_headers_on_fresh_worker_reflect_shared_redis_usageflaked once. Attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38105284067 (router shard ata192f28e) failed withassert 99 == 93onx-ratelimit-remaining-requests, and attempt 2 of the same run at the same sha passed. Mechanism is wall-clock dependence. Router usage counters are keyed by the current UTC minute fromlitellm.router.get_utc_datetime, and unlike its siblings this test did not use therouter_minute_pinnedfixture, so a minute rollover between the earlier calls and the streaming call left the streaming call counting into a fresh minute bucket. A scratch run that rolls the clock from 12:00:59 to 12:01:00 right before the streaming call reproduces the exact99 == 93failure on unfixed code. The fix adds@pytest.mark.usefixtures("router_minute_pinned"). Making the header computation read only the worker's in-memory cache instead of the shared store makes the fixed test fail, so it still guards cross-worker usage. The same commit also drops redundant comments fromtest_generic_api_callback.pytests/unit/integrations/test_custom_callback_input.py::test_logging_async_cache_hit_sync_call[True]also flaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38112337328 (integrations shard at1af25069), with an unredacted message in acache_hit=Truestandard logging payload, and attempt 2 at the same sha passed. It did not reproduce in 20 single-test repeats, 10 runs of its file under-n 4 --dist loadscope, or 5 runs of the whole integrations shard set, and forcing a delay into the async callback path did not trigger it either. The mechanism is not pinned, so this PR does not touch it and it is left for a human to look atNot flakes in the 2026-10-11 window
The root job in https://github.com/BerriAI/litellm/actions/runs/38121026296 failed on every attempt on a stale
tests/audio_testspath and a CircleCI step-count check, which is a real breakage and not a flake. Other failed jobs in the window were checkout timeouts and artifact upload or finalization errors, which are infraFlake evidence (run date 2026-10-10)
tests/unit/integrations/langfuse/test_langfuse_sdk.py::test_cold_prompt_miss_never_sleeps_when_langfuse_is_down[http-404]flaked twice, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/37981580881 (fix/responses-reasoning-item-shapeat8cd669aa) and attempt 1 of https://github.com/BerriAI/litellm/actions/runs/38036500873 (litellm_techdebt_20261010atbffd6e32). Neither branch touches Langfuse, and the first branch went green at the adjacent shaadcf7cc1in https://github.com/BerriAI/litellm/actions/runs/38000967073. The failures wereassert (142.47 - 141.27) < 0.5andassert (143.11 - 142.08) < 0.5with the request count already correct, so nothing slept and the runner was just slow. Mechanism is wall-clock dependence. The fix recordstime.sleepcalls in the generated Langfuse HTTP client the same way the neighboring auth-check test already does and asserts there were none. The same change goes intotest_one_transient_failure_on_a_cold_prompt_miss_does_not_fail_the_call, which used the samemonotonic() < 0.5check. Removingrequest_options=_NO_REST_RETRIESfrom_request_promptmakes both tests failtests/unit/integrations/generic_api/test_generic_api_callback.py::test_generic_api_callback_json_array_format_explicitflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/37989105125 (litellm_bedrock_grok_4_7_native_chat_completionsatc4684ddb, a Bedrock-only change that passed this test at02d9c165in https://github.com/BerriAI/litellm/actions/runs/37973323615). The post wasCalled 2 times, and the second batch held an event whose mock completion took 1.3s on the runner. Mechanism is wall-clock dependence. The 1speriodic_flushfired partway through the five calls and split the batch. The fix gives the logger a flush interval that never fires during a test, waits until every success event is inlog_queue, and then callsflush_queue()once. The other five tests in the file that usedflush_intervalplus a fixedasyncio.sleepget the same change. Sending each json_array entry as its own post makes the test fail withCalled 5 times. Since these tests now flush explicitly, a newtest_generic_api_callback_sends_queued_events_on_its_ownkeeps automatic sending covered. It uses a 0.05s flush interval, never callsflush_queue, waits until all three events have been posted, and asserts on what was sent rather than how many posts it took. Dropping theperiodic_flushtask from the constructor makes it failtests/unit/proxy/hooks/test_autorouter_baseline_cache.py::test_native_count_finishing_after_quarter_worker_budget_keeps_plan_and_spendflaked once, on attempt 1 of https://github.com/BerriAI/litellm/actions/runs/37914443287 (fix/router-latency-callback-registrationatfe106a48, which leaves the autorouter hook and the logging worker alone). It failed withreason='token_count_timeout'. The fake token counter waited a real 2.05s inside the planner's 3.0s budget, so about 0.95s of runner lag was enough to trip it, and an earlier deflake that moved the wait from 2.3s to 2.05s only narrowed the window. Mechanism is wall-clock dependence. The fix patchestimeon the running loop object so the loop clock reads 2.05s later once counting starts, which still lands past a quarter of the 8s worker budget, and the counter yields once so an already expired deadline gets to fire. The test now takes about 0.1s instead of 2.2s. Changing the planner'sfraction=0.75to0.25makes it fail withtoken_count_timeout, the same failure CI showedNone of the three reproduced locally in 20 repeats, whole-file xdist runs, or runs next to an 8 core CPU burn on main. The mechanisms come from the CI logs above. After the fix each test passed 20 of 20 repeats, and each whole owning file also passed both alone and under CPU burn
Not flakes in the 2026-10-10 window
tests/unit/harness/sandbox/test_docker.py::test_real_docker_roundtripfailed 35 times across many branches becausedocker run alpine:3.20could not pull from Docker Hub. That is infra and was left alone. The failures that only showed up on one branch, every run of it, followed what those branches changed, e.g.test_every_wif_kwarg_key_is_refused_from_a_client_router_configonlitellm_lit_6898_openai_wif_routesandtest_generation__input_reference_attachedonfeature/bytedance-video-adapter. Those are branch breakages, not flakes. No job in the window was re-run, so there was no same-sha attempt evidenceOther open deflake PRs
#43437, #42936 and #41219 each carry a human approval, so they stay open and untouched under the human-reviewed exception. This PR is the rolling PR and now also carries the 2026-10-11 through 2026-10-14 fixes
Pre-Submission checklist
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreScreenshots / Proof of Fix
Setup and client loop
Setup shared by both legs: a real FastMCP streamable HTTP server exposing
lookup_order(order_id, quantity), and a proxy booted withtaskset -c 0 python -m litellm.proxy.proxy_cli --config config.yaml --num_workers 2(one process, two workers, no DB) next to threetaskset -c 0 python -c 'while True: pass'loops standing in for a busy single-CPU pod. The config only registers the server (mcp_servers.qa_orders,transport: http) and a master key. The client does initialize, notifications/initialized, tools/list andsearch_toolson/mcp/proxy, then fires two batches of 8 concurrent curlsBefore (f088405)
{"detail":"MCP handler did not respond in time"}, median 30.03sAfter (58c6565)
"text":"LOOKUP_OK order_id=QA-cold-1 quantity=1"and"isError":false, median 16.21s, max 16.32sLOOKUP_OK, median 0.49s, max 0.54scall_toolargument validation is the only caller of the changed limiter, so this A/B also covers its whole live blast radius. Hosts whose affinity shows 4 or more CPUs keep the old 4 workersThe red
mainjobs pass at the tip:mcp-elicitationhttps://github.com/BerriAI/litellm/actions/runs/38698304869/job/116300269993 androuterhttps://github.com/BerriAI/litellm/actions/runs/38698304869/job/116300270133Type
🐛 Bug Fix
✅ Test
Caveats (if any)
Medium
Low
timeon the shared session event loop object, and monkeypatch puts it back at teardownFinal Attestation
The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
58c6565 passes /live-pr-risk
Link to Devin session: https://app.devin.ai/sessions/0be17c11676f4b398feaf8236149ee1e
Open in Devin Desktop: https://app.devin.ai/desktop/session/0be17c11676f4b398feaf8236149ee1e?variant=devin
Requested by: @mateo-berri
Note
Low Risk
The only runtime change tightens MCP schema validation concurrency on low-CPU hosts; remaining edits are test-only and do not alter production paths.
Overview
Production: MCP tool argument schema validation no longer always allows four process workers. The
anyiocapacity limiter is sized fromos.sched_getaffinity(when available), capped at four, so CPU-pinned proxies (e.g. one-core containers) avoid oversubscribing coldto_processworkers and hitting the 30s validation timeout on valid payloads.Tests: Deflakes CI by replacing brittle wall-clock assumptions—fake clocks for spend-log metadata miss TTL, pinned UTC minute for Redis prefetch and shared-Redis rate-limit headers, recorded Langfuse HTTP sleeps instead of
monotonic()bounds, event-loop time advance for autorouter token counting, direct event waits (and lock-contention checks) for MCP session lock tests, and a Generic API test that polls until periodic flush posts all events. The concurrent schema validation test now asserts spawned worker count stays within the affinity cap.Reviewed by Cursor Bugbot for commit 58c6565. Bugbot is set up for automated code reviews on this repo. Configure here.