Skip to content

Research guard test: watch the provider_credentials module the probe imports (order-dependent m-r failure) - #18112

Merged
danielhanchen merged 1 commit into
mainfrom
ci-research-guard-test-live-modules
Nov 17, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-research-guard-test-live-modules

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

studio/backend/tests/test_research_connection_context.py::test_window_probe_reads_the_connection_under_its_config_guard fails on some workers in the Studio m-r shard on unrelated PRs (staging runs of #18003 and #18087):

assert guarded and all(guarded)
E   assert ([False, False, False, False, False, False, ...] and False)

Cause

The test looks up held locks in provider_credentials._provider_config_locks after from routes import provider_credentials. Several other test files (test_credential_routes.py, test_provider_max_output_tokens_contract.py, test_provider_model_capabilities.py, ...) load private copies of routes.provider_credentials and pop it from sys.modules. On a worker where the real module had been imported before that, the routes package attribute still points at the old module while sys.modules has none. The probe's lazy from routes.provider_credentials import provider_config_guard then imports a fresh copy and locks that copy's table, while the test inspects the old one, so every read looks unguarded.

The probe does take the guard; only the test was looking at the wrong module.

Fix

The test resolves routes.provider_credentials through importlib.import_module (the same sys.modules lookup the probe's import uses) and patches get_provider_api_key on the credential_secrets module core.research_runs actually calls.

Verification

  • With a preceding test that imports routes.provider_credentials and pops it from sys.modules (the state those files leave):
    • main: fails with the CI assertion ([False, False, ...]).
    • this branch: passes.
  • Alone: 7 passed.
  • Sabotage: dropping async with provider_config_guard(...) from _guarded_connection_client makes the test fail on this branch, so it still checks the guard.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T07:59:43.411961Z 435bf3a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 435bf3ae71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 467e2b2 into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the ci-research-guard-test-live-modules branch November 17, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant