fix(agentic): honor iterations_limit in builds#14094
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe assistant iteration budget now uses a shared default, supports bounded per-request overrides, and propagates Python-flow overrides through graph loading into Agent ChangesAssistant iteration budget
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant load_graph_for_execution
participant _load_graph_from_python
participant get_graph
participant AgentComponent
Client->>load_graph_for_execution: provide ITERATIONS_LIMIT
load_graph_for_execution->>_load_graph_from_python: pass provider_vars
_load_graph_from_python->>get_graph: pass iterations_limit
get_graph->>AgentComponent: set bounded max_iterations
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 8 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (8 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
✅ Test Coverage AdvisorNo source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉
|
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
erichare
left a comment
There was a problem hiding this comment.
Hey @Cristhianzl , could you take a look at these findings?
Code Review Summary
Found 2 critical issues that need to be fixed:
🔴 Critical (Must Fix)
1. [P1] Nested component generation bypasses the iteration budget
FilePath: src/backend/base/langflow/agentic/services/helpers/flow_loader.py line 176
Related: src/lfx/src/lfx/mcp/flow_builder_tools/run_tools.py line 424
global_variables={"FLOW_ID": flow_id}Explanation
/iterations 1 limits the outer Python builder, but GenerateComponent launches a nested JSON assistant without ITERATIONS_LIMIT. That Agent therefore retains the default budget of 30 calls per attempt, defeating the cost cap for component_then_flow requests.
Suggested Fix
Carry the budget through task-local context and include it in the nested subflow’s globals. Add a regression test covering iteration-limited custom-component builds.
2. [P1] The existing loader test suite now fails
FilePath: src/backend/base/langflow/agentic/services/helpers/flow_loader.py line 237
return await _load_graph_from_python(flow_path, provider, model_name, api_key_var, provider_vars)Explanation
The loader now always supplies a fifth argument, including None, but assertions in test_flow_loader.py lines 372 and 425 still expect four arguments.
Reproduced on the current head: 2 failed, 26 passed. GitHub’s unit-test shards were still running when reviewed.
Suggested Fix
Update both mock expectations to include provider_vars=None, and add explicit non-None forwarding coverage.
Found 1 suggestion for improvement:
🟡 Suggestions (Should Consider)
1. [P2] Non-streaming endpoints silently ignore iterations_limit
FilePath: src/backend/base/langflow/agentic/api/router.py line 292
Explanation
AssistantRequest accepts iterations_limit, but only /assist/stream forwards it. /assist and /execute/{flow_name} accept the same schema yet silently execute with the default budget.
Suggested Fix
Seed ITERATIONS_LIMIT centrally in the resolved global variables, or explicitly forward it from every endpoint using AssistantRequest. Add route-level regression tests.
✅ What's Good
- Reviewed current head
97d7ef4against base4f86736. - The primary streaming Python-builder path correctly applies the budget.
- All 13 PR-added iteration tests passed.
- Ruff and
git diff --checkpassed. - Generated component-index and starter-project checks passed.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-1.11.0 #14094 +/- ##
==================================================
- Coverage 60.87% 60.87% -0.01%
==================================================
Files 2375 2426 +51
Lines 234025 236737 +2712
Branches 32939 37019 +4080
==================================================
+ Hits 142472 144114 +1642
- Misses 89842 90914 +1072
+ Partials 1711 1709 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Build successful! ✅ |
Summary
QA reopened the iterations-budget work (follow-up to #14038):
iterations_limitwas validated at the API and worked in isolation, but had no effect on real
builds —
iterations_limit=1still ran 6 model calls and completed.Summary by CodeRabbit
New Features
/iterations N./iterations offto restore the default limit of 30 steps.Documentation