Skip to content

chore: sync workflow templates - #848

Merged
stranske merged 1 commit into
mainfrom
sync/workflows-189df65808d0
Jun 22, 2026
Merged

chore: sync workflow templates#848
stranske merged 1 commit into
mainfrom
sync/workflows-189df65808d0

Conversation

@stranske

@stranske stranske commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Sync Summary

Files Updated

  • llm_provider.py: LLM provider configuration - GitHub Models and OpenAI client setup
  • langchain_client.py: LangChain client builder - multi-provider client with slot-based fallback and configuration

Files Skipped

  • renovate.json: File exists and sync_mode is create_only
  • cross-repo-smoke.yml: File exists and sync_mode is create_only
  • llm_slots.json: None

Review Checklist

  • CI passes with updated workflows
  • No repo-specific customizations were overwritten

Source: stranske/Workflows
Source SHA: 9eda7b48d198b4559dcde7d25deec18a6a917468
Template hash: 189df65808d0
Sync branch: sync/workflows-189df65808d0
Consumer repo: stranske/Template
Manifest: .github/sync-manifest.yml

Summary by CodeRabbit

  • Bug Fixes
    • Improved resilience when optional dependencies are unavailable, allowing Anthropic-only configurations to work properly
    • Enhanced model configuration fallback logic to provide more predictable behavior

Automated sync from stranske/Workflows
Template hash: 189df65808d0

Changes synced from sync-manifest.yml
@stranske stranske added sync Automated sync from Workflows automated Automated sync from Workflows labels Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ccfe6f6d-f9f0-4b0f-9800-200175d9ae51

📥 Commits

Reviewing files that changed from the base of the PR and between 2c11aec and 0ab3a95.

📒 Files selected for processing (2)
  • tools/langchain_client.py
  • tools/llm_provider.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • stranske/Workflows (auto-detected)
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

In Manager-Database repository using Prefect 2.x, import schedules from prefect.client.schemas.schedules rather than other locations

Files:

  • tools/llm_provider.py
  • tools/langchain_client.py
🔀 Multi-repo context stranske/Workflows

Based on my exploration of the source repository stranske/Workflows, I have found substantial cross-repository context relevant to this PR. Here are my findings:

Linked repositories findings

stranske/Workflows

Impact on tools/langchain_client.py changes:

[::stranske/Workflows::] The build_chat_client() and build_chat_clients() functions now gracefully tolerate missing langchain_openai imports by setting chat_openai_cls = None instead of failing immediately. This enables Anthropic-only scenarios. The GitHub Models client construction is now gated on chat_openai_cls availability (line 207: if not github_token or not chat_openai_cls), since GitHub Models still relies on the OpenAI-compatible chat class.

Consumers of the modified APIs:

[::stranske/Workflows::] Both OpenAIProvider and AnthropicProvider in tools/llm_provider.py (lines 599-611, 671-686) call build_chat_client() and check for falsy returns:

model_name = _configured_langchain_model("openai", fallback=DEFAULT_OPENAI_ANALYSIS_MODEL)
if not model_name:
    return None
resolved = build_chat_client(provider="openai", model=model_name)
if resolved:
    self._model_name = resolved.model
    return resolved.client

This pattern expects the new behavior where missing imports don't cause exceptions.

[::stranske/Workflows::] Multiple LangChain automation scripts import and use these builders:

  • scripts/langchain/_llm_client.py - Shared helper wrapping build_chat_client and build_chat_clients
  • scripts/langchain/issue_optimizer.py, pr_verifier.py, progress_reviewer.py - All import from tools.langchain_client

Test validation of the changes:

[::stranske/Workflows::] Comprehensive test suite in tests/tools/test_langchain_client.py (551 lines) explicitly validates:

  • Anthropic-only environments without langchain_openai installed (test: test_build_chat_client_anthropic_without_openai_package)
  • GitHub Models availability checks including chat_openai_cls guard (test: test_build_chat_clients_github_models_path)
  • Provider fallback chain with missing OpenAI package (test: test_build_chat_clients_anthropic_without_openai_package)

Changes to tools/llm_provider.py:

[::stranske/Workflows::] The _configured_langchain_model() function (lines 47-53) now strictly uses None checks instead of falsy checks:

configured = configured_model_for_provider(provider, fallback=fallback)
return fallback if configured is None else configured

This prevents falsy model names (empty strings, 0, etc.) from being replaced with fallback values.

Provider-specific gating:

[::stranske/Workflows::] In build_chat_client() slot-based fallback (lines 282-313), GitHub Models availability now requires both github_token AND chat_openai_cls:

slot_available = any(
    (
        slot.provider == PROVIDER_OPENAI and openai_token,
        slot.provider == PROVIDER_ANTHROPIC and anthropic_token and chat_anthropic_cls,
        slot.provider == PROVIDER_GITHUB and github_token and chat_openai_cls,  # Both required
    )
)

Related documentation:

[::stranske/Workflows::] The sync manifest (.github/sync-manifest.yml) explicitly marks both files for syncing:

  • tools/langchain_client.py - "LangChain client builder - multi-provider client with slot-based fallback"
  • tools/llm_provider.py - "LLM provider configuration - GitHub Models and OpenAI client setup"

Both are delivered via copy-sync (not runtime-fetch) to consumer repos, making these changes directly affect all consumer workflows that use LLM providers.

Risk assessment from cross-repo context:

The changes are backwards compatible at the function signature level but introduce behavioral changes that require verification in consumers:

  1. Code relying on exceptions from missing OpenAI imports may need to handle None returns instead
  2. GitHub Models selection now requires both the token AND the package to be installed
  3. Model name fallback behavior changes from loose falsy checks to strict None checks
🔇 Additional comments (2)
tools/llm_provider.py (1)

52-53: LGTM!

Also applies to: 605-606, 680-681

tools/langchain_client.py (1)

207-209: LGTM!

Also applies to: 236-240, 251-255, 297-305, 324-327, 350-352, 389-394, 409-409, 419-424, 439-439, 486-490, 505-510, 535-540


📝 Walkthrough

Walkthrough

tools/langchain_client.py converts langchain_openai ImportError from an immediate abort into a None sentinel (chat_openai_cls = None), gating all OpenAI and GitHub client construction paths on that sentinel while allowing Anthropic to proceed. tools/llm_provider.py tightens model resolution by checking explicitly for None rather than using or, and adds early-return guards in OpenAIProvider._get_client() and AnthropicProvider._get_client() when the resolved model name is falsy.

Changes

Optional langchain_openai and provider model guards

Layer / File(s) Summary
Provider model resolution and falsy model name guards
tools/llm_provider.py
_configured_langchain_model() uses an explicit None check instead of or fallback. OpenAIProvider._get_client() and AnthropicProvider._get_client() return None early when the resolved model name is falsy.
langchain_openai import failure → chat_openai_cls=None sentinel
tools/langchain_client.py
ImportError for langchain_openai in both build_chat_client and build_chat_clients now sets chat_openai_cls = None instead of returning None/[], enabling Anthropic provider selection to continue.
chat_openai_cls gating across all build paths
tools/langchain_client.py
All explicit GitHub/OpenAI branches and slot auto-selection logic in build_chat_client and build_chat_clients now guard on chat_openai_cls being non-None and pass it explicitly into _build_openai_client and _build_github_client.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • stranske/Template#841: Directly modifies the same build_chat_client/build_chat_clients provider and model selection logic in tools/langchain_client.py.
  • stranske/Template#847: Rewires tools/llm_provider.py providers to call build_chat_client, making it directly affected by this PR's client-building gating changes.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'chore: sync workflow templates' does not match the actual changes, which involve significant logic modifications to langchain_client.py and llm_provider.py for handling missing dependencies and model resolution. Update the title to reflect the actual code changes, such as 'fix: handle missing langchain_openai gracefully' or 'refactor: improve LLM provider and client initialization logic'.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 sync/workflows-189df65808d0

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

@stranske-keepalive

stranske-keepalive Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 05c2a2f
Latest Runs: ⏳ pending — Gate
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 100.00%
Baseline 0.00%
Delta +100.00%
Minimum 70.00%
Status ✅ Pass

Top Coverage Hotspots (lowest coverage)

File Coverage Missing
src/my_project/__init__.py 100.0% 0

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 temporarily deployed to agent-standard June 22, 2026 14:00 — with GitHub Actions Inactive
@stranske
stranske merged commit f908778 into main Jun 22, 2026
78 of 92 checks passed
@stranske
stranske deleted the sync/workflows-189df65808d0 branch June 22, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Automated sync from Workflows sync Automated sync from Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant