Skip to content

fix(agent): remediate connected OpenAI models - #14363

Merged
erichare merged 4 commits into
release-1.11.2from
fix/openai-reasoning-tools-responses
Jul 31, 2026
Merged

fix(agent): remediate connected OpenAI models#14363
erichare merged 4 commits into
release-1.11.2from
fix/openai-reasoning-tools-responses

Conversation

@erichare

@erichare erichare commented Jul 31, 2026

Copy link
Copy Markdown
Member

What changed

  • apply the existing Responses API remediation directly to connected language-model instances before retrying the Agent
  • allow a narrowly matched OpenAI provider error to be considered when a connected model's provider identity is unavailable
  • tighten the match to the exact function tools with reasoning_effort are not supported constraint
  • regenerate the LFX component index and add regressions for connected, inline, unsupported, and unrelated-error paths

Why

Issue #14361 is valid on Langflow 1.10.2. The inline Agent model path has had an error-driven retry since 1.11.0, but an OpenAI Model component connected to the Agent bypasses it: provider identity is lost and the retry reuses the unchanged Chat Completions client.

The remediation remains error-driven rather than tied to gpt-5.6-luna. Any OpenAI model that returns this exact constraint can switch to the Responses API, while known non-OpenAI providers and models without a compatible use_responses_api setting are left unchanged.

Validation

  • 62 passed: remediation, Agent remediation, temperature-remediation regression, and component-index tests
  • Ruff check and format
  • full repository pre-commit suite, including generated-component, deprecated-import, and secret checks

Fixes #14361

Summary by CodeRabbit

  • New Features
    • Agent workflows now support automatic model remediation for directly connected models.
    • Remediation applies adjustments in place when possible and retries affected operations.
    • Configured models continue to retain applicable remediation settings for future runs.
  • Bug Fixes
    • Improved provider-agnostic remediation matching and detection of unsupported-tool errors.
    • Failed connected-model adjustments now stop retries instead of applying ineffective changes.
  • Tests
    • Added coverage for connected-model remediation, unknown providers, and unrelated errors.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0efb14e2-efb6-4fc2-bb36-5d9a7b8323cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The Agent remediation flow now distinguishes connected model instances from configured model selections. It applies overrides directly to connected models, caches overrides only for unconnected models, and validates the updated behavior and error matching.

Changes

Model remediation

Layer / File(s) Summary
Remediation matching and error markers
src/lfx/src/lfx/base/models/model_remediation.py, src/lfx/tests/unit/base/models/test_model_remediation.py
Provider-agnostic matching now accepts unknown providers. The OpenAI marker targets the specific unsupported-tools error. Tests cover both cases.
Connected-model remediation runtime
src/lfx/src/lfx/components/models_and_agents/agent.py, src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py
Agent remediation resolves connected model context, applies overrides in place, retries successful changes, and aborts when overrides cannot be applied. Tests cover caching and retry behavior.
Starter project Agent snapshots
src/backend/base/langflow/initial_setup/starter_projects/*.json
Embedded Agent implementations and code hashes were updated across the starter projects. Connected models receive direct remediation, while configured models retain cached overrides.
Component index synchronization
src/lfx/src/lfx/_assets/component_index.json
The indexed Agent implementation, component hash, and aggregate checksum were regenerated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: cristhianzl

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Excessive Mock Usage Warning ⚠️ Warning The 182-line Agent remediation test patches 4–5 internal Agent methods in every case and uses AsyncMock/MagicMock for execution, setup, and model requirements, obscuring real interactions. Use real FakeListChatModel-based requirements and runnable setup where practical. Keep mocks only at the provider boundary, and add an integration test for the connected-model retry path.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the agent fix for connected OpenAI model remediation.
Linked Issues check ✅ Passed The changes address issue #14361 by remediating connected OpenAI models, matching the specific error, retrying, and adding regression tests.
Out of Scope Changes check ✅ Passed The changes remain within scope: agent remediation, matching logic, regenerated embedded components, and related regression tests.
Test Coverage For New Implementations ✅ Passed The PR updates two convention-compliant Python unit test files with regressions for provider matching, connected-model retry, unsupported connected models, and unrelated errors.
Test Quality And Coverage ✅ Passed Tests use pytest async patterns and assert exact remediation matching, provider filtering, connected-model mutation, retry counts, failure propagation, and cache behavior.
Test File Naming And Structure ✅ Passed Both changed tests use test_*.py under unit directories, valid pytest classes/async tests, descriptive names, cache cleanup, and positive plus negative cases. No frontend or integration tests changed.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openai-reasoning-tools-responses

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added the bug Something isn't working label Jul 31, 2026
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2026
@erichare
erichare marked this pull request as ready for review July 31, 2026 18:06
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Advisor

No source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉

Advisory check only — never blocks merge.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2026

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json (1)

1413-1585: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Use one remediation flow for every tool-enabled Agent output.

The new retry logic exists only in message_response. Tool-enabled json_response can still fail without applying the connected-model override. Regenerate each embedded implementation and its code hash after fixing the shared source.

  • src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json#L1413-L1585: update the research Agent fallback and regenerate its code hash.
  • src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json#L2044-L2216: update the itinerary Agent fallback and regenerate its code hash.
  • src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json#L2675-L2847: update the budget Agent fallback and regenerate its code hash.
  • src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json#L1010-L1182: update the Twitter Agent fallback and regenerate its code hash.
🤖 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 `@src/backend/base/langflow/initial_setup/starter_projects/Travel` Planning
Agents.json around lines 1413 - 1585, Apply the same connected-model override
and retry remediation used by the message_response path to the json_response
fallback in AgentComponent, ensuring every tool-enabled Agent output follows one
remediation flow. Update the embedded implementations at
src/backend/base/langflow/initial_setup/starter_projects/Travel Planning
Agents.json lines 1413-1585, 2044-2216, and 2675-2847, plus
src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread
Generator.json lines 1010-1182; regenerate each corresponding code_hash after
synchronizing the shared AgentComponent implementation.
🧹 Nitpick comments (1)
src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py (1)

67-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the redundant asyncio markers.

pytest-asyncio auto-detects async tests in this repository.

  • src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py#L67-L68: Remove @pytest.mark.asyncio.
  • src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py#L111-L112: Remove @pytest.mark.asyncio.
  • src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py#L146-L147: Remove @pytest.mark.asyncio.

Based on learnings, asyncio_mode = 'auto' means tests must not add pytest.mark.asyncio.

🤖 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
`@src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py`
around lines 67 - 68, Remove the redundant `@pytest.mark.asyncio` decorators from
test_message_response_remediates_a_connected_model_in_place_without_caching and
the async tests at
src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py
lines 111-112 and 146-147; rely on the repository’s asyncio_mode = 'auto'
configuration.

Sources: Coding guidelines, Learnings

🤖 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 `@src/backend/base/langflow/initial_setup/starter_projects/Vector` Store
RAG.json:
- Line 1847: The structured-output fallback in AgentComponent’s json_response
currently calls run_agent directly, bypassing connected-model remediation. In
both src/backend/base/langflow/initial_setup/starter_projects/Vector Store
RAG.json:1847-1847 and
src/backend/base/langflow/initial_setup/starter_projects/Youtube
Analysis.json:676-676, update _run_agent_for_fallback to reuse the shared
remediation helper used by message_response, and add regression coverage for
both embedded Agent implementations.

---

Outside diff comments:
In `@src/backend/base/langflow/initial_setup/starter_projects/Travel` Planning
Agents.json:
- Around line 1413-1585: Apply the same connected-model override and retry
remediation used by the message_response path to the json_response fallback in
AgentComponent, ensuring every tool-enabled Agent output follows one remediation
flow. Update the embedded implementations at
src/backend/base/langflow/initial_setup/starter_projects/Travel Planning
Agents.json lines 1413-1585, 2044-2216, and 2675-2847, plus
src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread
Generator.json lines 1010-1182; regenerate each corresponding code_hash after
synchronizing the shared AgentComponent implementation.

---

Nitpick comments:
In
`@src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py`:
- Around line 67-68: Remove the redundant `@pytest.mark.asyncio` decorators from
test_message_response_remediates_a_connected_model_in_place_without_caching and
the async tests at
src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py
lines 111-112 and 146-147; rely on the repository’s asyncio_mode = 'auto'
configuration.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 12a5461d-47ce-4267-9dd8-5b8dabae79ec

📥 Commits

Reviewing files that changed from the base of the PR and between b1034af and 63f1b16.

📒 Files selected for processing (29)
  • src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json
  • src/backend/base/langflow/initial_setup/starter_projects/Content Aggregator.json
  • src/backend/base/langflow/initial_setup/starter_projects/Custom Component Generator.json
  • src/backend/base/langflow/initial_setup/starter_projects/Deep Research Agent.json
  • src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json
  • src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json
  • src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json
  • src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json
  • src/backend/base/langflow/initial_setup/starter_projects/Market Research.json
  • src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json
  • src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json
  • src/backend/base/langflow/initial_setup/starter_projects/Multi Agent Flow.json
  • src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json
  • src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json
  • src/backend/base/langflow/initial_setup/starter_projects/SEO Keyword Generator.json
  • src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json
  • src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json
  • src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json
  • src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json
  • src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json
  • src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json
  • src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json
  • src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json
  • src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json
  • src/lfx/src/lfx/_assets/component_index.json
  • src/lfx/src/lfx/base/models/model_remediation.py
  • src/lfx/src/lfx/components/models_and_agents/agent.py
  • src/lfx/tests/unit/base/models/test_model_remediation.py
  • src/lfx/tests/unit/components/models_and_agents/test_agent_model_remediation.py

Comment thread src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json Outdated
@erichare

Copy link
Copy Markdown
Member Author

Addressed the remaining review feedback in 4d073ff: strict provider matching, validated connected-model provenance, alternate Responses API wording, real requirement-resolution coverage, and documented flow-scoped mutation. Forward-port intentionally deferred.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.45%. Comparing base (e0bcbfd) to head (22353a9).
⚠️ Report is 6 commits behind head on release-1.11.2.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.11.2   #14363      +/-   ##
==================================================
- Coverage           61.57%   61.45%   -0.13%     
==================================================
  Files                2411     2452      +41     
  Lines              238468   239862    +1394     
  Branches            33755    34178     +423     
==================================================
+ Hits               146836   147405     +569     
- Misses              89832    90651     +819     
- Partials             1800     1806       +6     
Flag Coverage Δ
backend 66.72% <ø> (-2.22%) ⬇️
frontend 60.21% <ø> (+0.38%) ⬆️
lfx 60.73% <ø> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/lfx/src/lfx/base/models/model_remediation.py 82.97% <ø> (ø)

... and 348 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erichare

Copy link
Copy Markdown
Member Author

Addressed in 22353a9: missing source vertices now degrade to unknown provider instead of aborting Agent execution, with coverage for the ValueError path and all three source-provider branches. I did not backport provider canonicalization: _canonical_provider_name is not present on release-1.11.2 (it arrived with newer 1.12.0 provider-registry work), and this branch already supplies canonical provider names. The same four custom-prompt assertions reproduce at base b1034af (4 failed, 4 passed). Validation: pre-commit green; 132 passed, 2 skipped; 282 passed, 10 skipped, 8 deselected. No forward-port included.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 47%
47.33% (67565/142734) 70.29% (9507/13525) 45.8% (1555/3395)

Unit Test Results

Tests Skipped Failures Errors Time
5401 0 💤 0 ❌ 0 🔥 20m 55s ⏱️

@erichare
erichare merged commit d3d7007 into release-1.11.2 Jul 31, 2026
267 of 270 checks passed
@erichare
erichare deleted the fix/openai-reasoning-tools-responses branch July 31, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function tools with reasoning_effort are not supported for gpt-5.6-luna

1 participant