Add endpoint probe, rename cost_probe, and add PR/probe interval throttling#106
Merged
Merged
Conversation
…tale data _build_models_list now skips the _models_list_cache write when called with only_if_empty=True and the cache is already populated. This prevents two races: 1. Within-test: the startup daemon thread (step 5 of _run_startup_tasks_once) overwrote a fresh cache built by list_models() on a concurrent request. 2. Cross-test: a daemon thread left over from a prior test (after monkeypatches were torn down) wrote an empty cache to the module dict after a module reload reset it to None, causing the next test's list_models() to see a stale cache hit. Also suppress startup daemon threads and interval probe checks in the test_proxy_display_id_format server fixture to eliminate remaining cross-test contamination from prior tests' threads writing with old lock instances. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RkRhX4Znv73oPcZy41bnyS
… fixtures _maybe_fire_interval_probes() spawns background daemon threads that run the full update pipeline. Under pytest-cov with concurrent threads, Python's coverage/collector.py:lock_data crashes with SIGSEGV (exit 139). After each importlib.reload(server_mod) the module globals reset, but old daemon threads from prior tests still run against the old lock instances — causing races. Patch both _run_startup_tasks_once and _maybe_fire_interval_probes to no-ops immediately after every reload in all 15 server-loading test helpers/fixtures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RkRhX4Znv73oPcZy41bnyS
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
probe→cost_probeeverywhere: source file (scripts/sources/cost_probe.py), class (CostProbeSource), config key (free_tier.cost_probe), state file (cost_probe_state.json), CLI flags (--cost-probe,--cost-probe-max). Back-compat migration copies oldprobe_state.jsonon first run.endpoint_probesource (scripts/sources/endpoint_probe.py): actively calls each configured provider'sGET /v1/modelsto discover new:free-suffix models and flag disappeared ones — gated by existingsync_on_startup/update_on_startupflags, throttled byfree_tier.endpoint_probe.frequency_minutes(default 30)._maybe_fire_interval_probes()(60 s in-memory gate) fires endpoint probe, cost probe, and PR creation as daemon threads when their respective intervals elapse.providers_pr.frequency_daysconfig key; state tracked inpr_state.jsonnext to the user config.DocsScraperBase.fetch(): up to 3 retries with Retry-After support, returns[]on exhaustion. Adds two new tests for the retry path._build_models_list: startup warmup (only_if_empty=True) no longer overwrites_models_list_cachewhen a concurrent request or a cross-test daemon thread already populated it.New config keys
State files (auto-created next to
config.json):endpoint_probe_state.json— trackslast_probe_atfor the endpoint probecost_probe_state.json— trackslast_probe_atfor the cost probe (migrated fromprobe_state.json)pr_state.json— trackslast_pr_atfor PR throttlingTest plan
test_probe_source.pyusesCostProbeSourcefromscripts.sources.cost_probetest_probe_throttle.pyusescost_probe_state.jsonpath helperstest_docs_huggingface.pycovers 429 retry and exhaustion pathstest_real_model_name_unchangedno longer flaky (startup daemon thread race fixed)test_admin_api.py::test_put_maintenance_sets_flagschecksfree_tier.cost_probekey🤖 Generated with Claude Code
https://claude.ai/code/session_01RkRhX4Znv73oPcZy41bnyS
Generated by Claude Code