Skip to content

fix: restore LLM slot bootstrap compatibility - #2796

Merged
stranske merged 1 commit into
mainfrom
fix/llm-slot-bootstrap-compat
Jul 20, 2026
Merged

fix: restore LLM slot bootstrap compatibility#2796
stranske merged 1 commit into
mainfrom
fix/llm-slot-bootstrap-compat

Conversation

@stranske

@stranske stranske commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Restores the documented emergency LANGCHAIN_MODEL bootstrap when bundled slots yield no usable entries, while retaining fail-closed behavior for explicit LANGCHAIN_SLOT_CONFIG. Loaded registry entries again expose an empty compatibility quality mapping.\n\nValidation:\n- python -m pytest tests/tools/test_langchain_client.py tests/tools/test_llm_registry_selection.py -q\n- python scripts/validate_template_sync.py

Summary by CodeRabbit

  • Bug Fixes
    • Improved model registry compatibility by consistently representing unsupported quality metadata as an empty value.
    • Improved fallback model setup when no slot configuration is available, including environments with an existing but unusable configuration file.
    • Explicitly configured environment models now resolve across supported providers in this fallback scenario.

Copilot AI review requested due to automatic review settings July 20, 2026 06:31
@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@stranske-keepalive

Copy link
Copy Markdown
Contributor

Workflow source needed

PR #2796 needs either a linked GitHub issue or one valid non-issue Workflow Source before PR metadata automation can manage it safely.

Please do one of:

  • Add <!-- meta:issue:123 --> or a normal Closes #123 / Related to #123 line.
  • Check one Workflow Source option in the PR body.
  • Add a hidden marker such as <!-- workflow-source:local_request -->, <!-- workflow-source:manual_remote -->, <!-- workflow-source:review_followup -->, <!-- workflow-source:sync_campaign -->, or <!-- workflow-source:dependabot -->.
  • Add a workflow source label such as workflow:source-direct-pr, workflow:source-local-request, workflow:source-review-followup, workflow:source-sync, or workflow:no-automation.

Once a valid source is present, this warning will not be reposted.

@stranske
stranske temporarily deployed to agent-standard July 20, 2026 06:32 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes initialize loaded registry entries with quality={} and broaden emergency slot bootstrapping for explicit environment models. Tests update registry-quality expectations and verify resolved slots across OpenAI, Anthropic, and GitHub Models providers.

Changes

LLM registry updates

Layer / File(s) Summary
Registry quality initialization
tools/llm_registry.py, templates/consumer-repo/tools/llm_registry.py, tests/tools/test_langchain_client.py, tests/tools/test_llm_registry_selection.py
Loaded registry entries now explicitly use empty quality mappings, with tests covering malformed, legacy, and compatibility quality values.
Environment-model slot bootstrap
tools/llm_registry.py, templates/consumer-repo/tools/llm_registry.py, tests/tools/test_llm_registry_selection.py
Explicit environment models bootstrap slots when no slots are loaded, including when the bundled slot path exists; tests expect provider-specific resolutions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: maintenance, sync

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: restoring LLM slot bootstrap compatibility behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/llm-slot-bootstrap-compat

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tools/llm_registry.py (1)

438-444: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject whitespace-only emergency model values in both registry implementations.

Both resolve_slots() guards use raw environment-variable truthiness while downstream slot resolution strips the model. A whitespace-only LANGCHAIN_MODEL therefore triggers bootstrap but produces only empty models.

  • tools/llm_registry.py#L438-L444: check os.environ.get(env_model_name, "").strip() before bootstrapping.
  • templates/consumer-repo/tools/llm_registry.py#L438-L444: apply the identical non-blank guard to keep the canonical template synchronized.

As per path instructions: **/*.py: Prioritize correctness, error handling, and test coverage. Flag new or changed behavior with no accompanying test, silently swallowed exceptions, and unguarded NaN/None propagation in numeric or scoring code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/llm_registry.py` around lines 438 - 444, Update the resolve_slots()
emergency bootstrap guard in tools/llm_registry.py (438-444) to require
os.environ.get(env_model_name, "").strip() before creating slots, and apply the
identical change in templates/consumer-repo/tools/llm_registry.py (438-444) to
keep both registry implementations synchronized.

Source: Path instructions

tests/tools/test_llm_registry_selection.py (1)

210-226: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that the emergency model is actually applied.

The test checks only provider names, so it would pass even if bootstrap returned three placeholder slots with model="" and never applied "emergency-model".

Proposed test improvement
-    assert [slot.provider for slot in registry.resolve_slots()] == [
+    slots = registry.resolve_slots()
+    assert [slot.provider for slot in slots] == [
         "openai",
         "anthropic",
         "github-models",
     ]
+    assert slots[0].model == "emergency-model"

As per path instructions: **/*.py: Prioritize correctness, error handling, and test coverage. Flag new or changed behavior with no accompanying test, silently swallowed exceptions, and unguarded NaN/None propagation in numeric or scoring code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/test_llm_registry_selection.py` around lines 210 - 226,
Strengthen test_unusable_bundled_slot_config_bootstraps_explicit_env_model by
asserting the resolved slot models include the LANGCHAIN_MODEL value
"emergency-model", not only their providers. Preserve the existing provider
assertions while verifying bootstrap applies the explicit environment model
rather than returning placeholder slots.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/tools/test_llm_registry_selection.py`:
- Around line 210-226: Strengthen
test_unusable_bundled_slot_config_bootstraps_explicit_env_model by asserting the
resolved slot models include the LANGCHAIN_MODEL value "emergency-model", not
only their providers. Preserve the existing provider assertions while verifying
bootstrap applies the explicit environment model rather than returning
placeholder slots.

In `@tools/llm_registry.py`:
- Around line 438-444: Update the resolve_slots() emergency bootstrap guard in
tools/llm_registry.py (438-444) to require os.environ.get(env_model_name,
"").strip() before creating slots, and apply the identical change in
templates/consumer-repo/tools/llm_registry.py (438-444) to keep both registry
implementations synchronized.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab9e74aa-021a-4159-8792-ab2870a79d07

📥 Commits

Reviewing files that changed from the base of the PR and between 57a384d and fbd2f8f.

📒 Files selected for processing (4)
  • templates/consumer-repo/tools/llm_registry.py
  • tests/tools/test_langchain_client.py
  • tests/tools/test_llm_registry_selection.py
  • tools/llm_registry.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbd2f8fcea

ℹ️ 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".

Comment thread tools/llm_registry.py
and not _slot_path().exists()
and os.environ.get(env_model_name)
):
if not slots and not os.environ.get(ENV_SLOT_CONFIG) and os.environ.get(env_model_name):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the default slot allowlist during bootstrap

When a consumer has customized the create-only config/llm_slots.json at the default path so no slots are usable (for example an empty slot list or only disabled/unknown providers) while leaving LANGCHAIN_SLOT_CONFIG unset, this now expands that empty allowlist into OpenAI/Anthropic/GitHub whenever LANGCHAIN_MODEL is present. The synced agents-issue-optimizer.yml and agents-auto-pilot.yml workflows set LANGCHAIN_MODEL, so those repos can start invoking LLM clients despite their local default slot file intentionally restricting or disabling slots; keep the emergency bootstrap limited to a missing default slot file, or otherwise distinguish an intentionally empty default config from a missing registry.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the documented “emergency” LANGCHAIN_MODEL bootstrap path when the bundled/default slot config resolves to no usable slots, while keeping fail-closed behavior for explicitly configured LANGCHAIN_SLOT_CONFIG. It also re-establishes an explicit (empty) v1-compatibility quality mapping on loaded registry entries.

Changes:

  • Ensure load_model_registry() emits entries with quality == {} (compatibility surface) instead of None.
  • Allow resolve_slots() to bootstrap placeholder slots when bundled/default slots are unusable and LANGCHAIN_MODEL is set (but still not when LANGCHAIN_SLOT_CONFIG is explicitly set).
  • Update test expectations and scenarios to cover the restored bootstrap behavior and the empty quality mapping.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tools/llm_registry.py Restores env-model bootstrap on empty bundled slot resolution; sets quality={} on loaded registry entries.
templates/consumer-repo/tools/llm_registry.py Mirrors the same registry + slot bootstrap behavior for consumer template sync.
tests/tools/test_llm_registry_selection.py Updates tests to expect quality == {} and to assert bundled-slot unusable case bootstraps env model.
tests/tools/test_langchain_client.py Updates registry-loading tests to expect quality == {} for malformed/legacy inputs.

Comment thread tools/llm_registry.py
Comment on lines 435 to 437
# Preserve an explicit runtime override as an emergency bootstrap when the
# registry file is unavailable. Empty models are never invoked directly;
# langchain_client skips them when the override cannot serve that provider.
Comment on lines 435 to 437
# Preserve an explicit runtime override as an emergency bootstrap when the
# registry file is unavailable. Empty models are never invoked directly;
# langchain_client skips them when the override cannot serve that provider.
@stranske-keepalive

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 6e67d37
Latest Runs: ⏳ pending — Gate
Required contexts: Gate / gate, Health 45 Agents Guard / guard
Required: core tests (3.12): ⏳ pending, core tests (3.13): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 75.72%
Baseline 85.00%
Delta -9.28%
Minimum 70.00%
Status ✅ Pass

Top Coverage Hotspots (lowest coverage)

File Coverage Missing
scripts/issue_dedup_smoke.py 0.0% 4
scripts/runner_lib/__main__.py 0.0% 3
scripts/validate_template_sync.py 0.0% 81
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/prune_agent_stubs.py 39.7% 26
scripts/repo_review_round1_runner.py 40.7% 133
tools/ensure_workflow_timeout_variables.py 42.1% 74
scripts/sync_label_docs.py 42.9% 64
tools/discover_model_catalog.py 44.8% 55
scripts/repo_review_backlog_scan.py 45.3% 116
scripts/repo_review_body_writer.py 46.5% 86
tools/codex_session_analyzer.py 47.9% 59
scripts/create_verifier_labels.py 48.3% 58

Low Coverage Files (<50.0%)

File Coverage Missing
scripts/issue_dedup_smoke.py 0.0% 4
scripts/runner_lib/__main__.py 0.0% 3
scripts/validate_template_sync.py 0.0% 81
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/prune_agent_stubs.py 39.7% 26
scripts/repo_review_round1_runner.py 40.7% 133
tools/ensure_workflow_timeout_variables.py 42.1% 74
scripts/sync_label_docs.py 42.9% 64
tools/discover_model_catalog.py 44.8% 55
scripts/repo_review_backlog_scan.py 45.3% 116
scripts/repo_review_body_writer.py 46.5% 86
tools/codex_session_analyzer.py 47.9% 59
scripts/create_verifier_labels.py 48.3% 58

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

No scope information available

Tasks

  • No tasks defined

Acceptance criteria

  • No acceptance criteria defined

@stranske
stranske merged commit 53f18ad into main Jul 20, 2026
56 checks passed
@stranske
stranske deleted the fix/llm-slot-bootstrap-compat branch July 20, 2026 08:27
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.

2 participants