Skip to content

fix: ignore tier slots with malformed registry - #2724

Merged
stranske merged 1 commit into
mainfrom
codex/fix-llm-slot-fallback-sync
Jun 30, 2026
Merged

fix: ignore tier slots with malformed registry#2724
stranske merged 1 commit into
mainfrom
codex/fix-llm-slot-fallback-sync

Conversation

@stranske

@stranske stranske commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • treat malformed model-registry payloads as a signal to keep the full default slot list when slot config depends on quality_tier resolution
  • keep valid partial registries using the existing provider fallback behavior
  • mirror the fix into the consumer template copy of tools/llm_registry.py

Validation

  • python3 -m pytest tests/tools/test_langchain_client.py tests/test_check_model_registry_freshness.py -q
  • python3 scripts/validate_template_sync.py
  • python3 scripts/validate_template_completeness.py
  • git diff --check
  • /opt/anaconda3/bin/python3.12 -m black --check tools/llm_registry.py templates/consumer-repo/tools/llm_registry.py tests/tools/test_langchain_client.py

Unblocks sync/dependency cleanup for stranske/Inv-Man-Intake#731, where malformed registry fallback currently resolves only the first provider slot instead of the complete default slot list.

Summary by CodeRabbit

  • Bug Fixes
    • Improved slot loading so configurations continue to work when the model registry file is missing or malformed.
    • If a slot depends on tier-based model selection and the registry can’t be read in the expected format, the app now falls back to default slots instead of failing or misconfiguring slots.
    • Added coverage to ensure tier-based slot selection is ignored when the registry configuration is invalid.

@stranske stranske added automation Automation and workflow automation maintenance Maintenance tasks sync codex codex-automation labels Jun 30, 2026
@stranske
stranske temporarily deployed to agent-standard June 30, 2026 13:32 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds _model_registry_format_valid() to both tools/llm_registry.py and its consumer-repo template copy. This helper checks that the model-registry config file, if present, parses as a JSON object with a models list. load_slot_config() is updated to precompute slot entries and return fallback_slots early when the registry format is invalid and any slot entry requires tier-based model resolution. A new test covers the invalid-registry fallback path.

Changes

Registry format validation and slot fallback

Layer / File(s) Summary
_model_registry_format_valid and load_slot_config early fallback
tools/llm_registry.py, templates/consumer-repo/tools/llm_registry.py
Adds _model_registry_format_valid() that returns False when the registry file exists but is not a JSON object with a models list. Updates load_slot_config() to precompute slot_entries once and return fallback_slots early when the registry is invalid and any slot entry specifies a tier without an explicit model.
Test: invalid registry fallback
tests/tools/test_langchain_client.py
Adds test_load_slot_config_ignores_tier_slot_when_registry_invalid which writes a JSON-array registry file and a tier-based slot config, then asserts load_slot_config() returns default_slots().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • stranske/Workflows#2496: Modifies the same load_slot_config and registry-format handling in templates/consumer-repo/tools/llm_registry.py with related LangChain client test updates.
  • stranske/Workflows#2718: Modifies load_slot_config slot fallback behavior in llm_registry.py, specifically how provider-based fallback models are selected when slot entries are missing models.

Suggested labels

langchain

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: tier-based slots are ignored when the model registry is malformed.
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 codex/fix-llm-slot-fallback-sync

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

@stranske-keepalive

Copy link
Copy Markdown
Contributor

Workflow source needed

PR #2724 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.

1 similar comment
@stranske-keepalive

Copy link
Copy Markdown
Contributor

Workflow source needed

PR #2724 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 enabled auto-merge (squash) June 30, 2026 13:32
@stranske-keepalive

stranske-keepalive Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 8705942
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.70%
Baseline 85.00%
Delta -9.30%
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% 77
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/ci_failure_triage.py 44.2% 123
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% 77
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/ci_failure_triage.py 44.2% 123
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

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@tools/llm_registry.py`:
- Around line 245-253: The early-fallback path in llm_registry is doing a
redundant second read/parse via _model_registry_format_valid() after
load_model_registry() has already loaded the same registry. Update the logic
around load_model_registry() and _model_registry_format_valid() so the fallback
decision reuses a single parse and gets validity/parse status from
load_model_registry() instead of re-reading the file. Keep the check in the same
branch that builds slot_entries and returns fallback_slots, but base it on the
already-loaded registry data and a shared validity signal.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3e00d214-508c-434e-bb5b-90fbfb6fa48e

📥 Commits

Reviewing files that changed from the base of the PR and between 46b1b3d and d703bb5.

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

Comment thread tools/llm_registry.py
Comment on lines 245 to +253
registry = load_model_registry()
slot_entries = _slot_entries(payload, path)
if not _model_registry_format_valid() and any(
str(entry.get("provider", "")).strip()
and not str(entry.get("model", "")).strip()
and str(entry.get("quality_tier") or entry.get("tier") or "").strip()
for entry in slot_entries
):
return fallback_slots

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Redundant registry read/parse on this path.

load_model_registry() (Line 245) already reads and parses the same file that _model_registry_format_valid() re-reads at Line 247, so the registry file is read and JSON-parsed twice per call. Beyond the extra I/O, the two have subtly different validity definitions (the validator only checks the top-level models is a list, while load_model_registry() also drops malformed entries), which can drift over time. Consider having load_model_registry() surface a validity/parse-status signal so the early-fallback decision reuses a single parse.

🤖 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 245 - 253, The early-fallback path in
llm_registry is doing a redundant second read/parse via
_model_registry_format_valid() after load_model_registry() has already loaded
the same registry. Update the logic around load_model_registry() and
_model_registry_format_valid() so the fallback decision reuses a single parse
and gets validity/parse status from load_model_registry() instead of re-reading
the file. Keep the check in the same branch that builds slot_entries and returns
fallback_slots, but base it on the already-loaded registry data and a shared
validity signal.

@stranske
stranske merged commit 057152b into main Jun 30, 2026
139 of 152 checks passed
@stranske
stranske deleted the codex/fix-llm-slot-fallback-sync branch June 30, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automation and workflow automation codex codex-automation maintenance Maintenance tasks sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants