Skip to content

fix(agent): Await Response pauses on every Loop iteration - #16794

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
ondery:fix/userfillup-loop-wait-each-iteration
Jul 10, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
ondery:fix/userfillup-loop-wait-each-iteration

Conversation

@ondery

@ondery ondery commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

An Await Response (UserFillUp) node placed inside a Loop now pauses and waits for a fresh user response on every iteration, instead of only on the first one.

Problem

When a UserFillUp node lives inside a Loop, it only paused for input on the first iteration. On subsequent iterations the loop ran straight through, silently reusing the answer the user gave the first time.

Root cause is in UserFillUp._invoke / the canvas wait-check (agent/canvas.py). The wait-check decides whether to pause by calling Canvas._is_input_field_satisfied on the node's form fields — a field counts as satisfied as soon as its value is not None:

@staticmethod
def _is_input_field_satisfied(field):
    ...
    if value is None:
        return False
    return True

The same component object is reused across loop iterations, and UserFillUp._invoke writes the answer into self._param.inputs[...]["value"] via set_input_value. Nothing cleared those values when the node was re-entered for the next iteration, so:

Iteration Entry (no answer yet) Field value Satisfied? Result
1 fresh None no pauses ✅
1 resume w/ answer answer yes continues ✅
2 fresh answer (stale) yes continues ❌ (should pause)

Fix

When a UserFillUp is entered without a fresh user answer (merged_inputs is empty), clear the retained form values so the wait-check treats the form as unsatisfied and pauses again:

merged_inputs = self._merge_runtime_inputs(kwargs.get("inputs", {}))
if not merged_inputs:
    self._clear_form_values()
  • Fresh entry / new loop iteration → no answer supplied → values cleared → node pauses and waits.
  • Resume with an answer → merged_inputs is non-empty → values applied normally, nothing cleared.
  • Non-loop behavior is unchanged: the first entry already had None values, so clearing is a no-op there.

Begin overrides _invoke and is unaffected.

Tests

Added to test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py:

  • test_user_fillup_clears_stale_values_on_reentry_without_answer — a retained value is cleared on a fresh entry with no answer (loop re-entry).
  • test_user_fillup_keeps_values_when_answer_supplied — a supplied answer is applied and not cleared.

All unit tests pass and ruff check is clean.

Scope

This targets the Python agent runtime (agent/). It is independent of any other in-flight Await Response change.

Copilot AI review requested due to automatic review settings July 9, 2026 19:18
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 782c6d19-8be9-4d5e-8d72-34aee7ffefb4

📥 Commits

Reviewing files that changed from the base of the PR and between d4011a7 and 7656e2e.

📒 Files selected for processing (2)
  • agent/component/fillup.py
  • test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py
  • agent/component/fillup.py

📝 Walkthrough

Walkthrough

UserFillUp now clears retained form values when re-entered with no merged inputs, while preserving optional file inputs. Tests cover clearing, updating, and file-input re-entry behavior.

Changes

Fillup Value Clearing

Layer / File(s) Summary
Guard and clearing helper in UserFillUp
agent/component/fillup.py
_invoke calls _clear_form_values() when no inputs are merged, clearing stored values except optional file inputs.
Unit tests for re-entry behavior
test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py
Tests clearing stale values, applying supplied answers to inputs and outputs, and preserving optional file values.

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

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant UserFillUp
  participant InputElements
  Caller->>UserFillUp: Invoke with merged inputs
  alt No merged inputs
    UserFillUp->>UserFillUp: Call _clear_form_values
    UserFillUp->>InputElements: Clear eligible values
  else Supplied answer
    UserFillUp->>InputElements: Set input and output values
  end
Loading

Poem

A rabbit hopped back through the form,
Empty paws, but values transform.
Old fields cleared, new answers bright,
File treasures stayed tucked in tight. 🐇

🚥 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
Title check ✅ Passed The title clearly summarizes the main change: UserFillUp now pauses again on each loop iteration.
Description check ✅ Passed The description is detailed and covers the purpose, problem, fix, tests, and scope, exceeding the template’s required summary.
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.

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.

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

🧹 Nitpick comments (1)
agent/component/fillup.py (1)

117-134: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add logging for the new clearing flow.

The new _clear_form_values guard is a new runtime flow (clearing stale form values on re-entry inside a Loop). No log statement is emitted when clearing occurs, making it difficult to diagnose loop-iteration pause issues in production. As per coding guidelines, new flows in **/*.py files should add logging.

♻️ Proposed addition of a debug log
 def _invoke(self, **kwargs):
     ...
     merged_inputs = self._merge_runtime_inputs(kwargs.get("inputs", {}))
     if not merged_inputs:
+        logging.debug("UserFillUp %s: no fresh inputs, clearing retained form values", self.component_name)
         self._clear_form_values()
     for k, v in merged_inputs.items():
     ...

 def _clear_form_values(self):
     for field in self.get_input_elements().values():
         if isinstance(field, dict):
             field["value"] = None
🤖 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 `@agent/component/fillup.py` around lines 117 - 134, Add a debug log for the
new clearing path in UserFillUp processing: when merged_inputs is empty and
_clear_form_values is called, emit a log message so loop re-entry can be
diagnosed in production. Update the fillup.py flow around _clear_form_values and
the merged_inputs guard to log that stale form values are being cleared before
waiting again, using the existing logging pattern in the component.

Source: Coding guidelines

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

Nitpick comments:
In `@agent/component/fillup.py`:
- Around line 117-134: Add a debug log for the new clearing path in UserFillUp
processing: when merged_inputs is empty and _clear_form_values is called, emit a
log message so loop re-entry can be diagnosed in production. Update the
fillup.py flow around _clear_form_values and the merged_inputs guard to log that
stale form values are being cleared before waiting again, using the existing
logging pattern in the component.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 682eefa6-5d2e-45a2-bc1c-3960097c95ec

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8b51c and 15967fc.

📒 Files selected for processing (2)
  • agent/component/fillup.py
  • test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py

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

This PR fixes the Python agent runtime behavior where an Await Response (UserFillUp) node inside a Loop would only pause on the first iteration and then silently reuse the previous iteration’s answers. It does this by clearing retained form values when the node is entered without any fresh runtime inputs, so the canvas wait-check sees the form as unsatisfied and pauses again.

Changes:

  • Clear UserFillUp input field values on entry when no fresh runtime inputs are provided, forcing re-prompting on loop re-entry.
  • Add unit tests validating that stale values are cleared on re-entry and that supplied answers are preserved/applied.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
agent/component/fillup.py Clears retained UserFillUp form values when entered without new inputs so the canvas wait-check pauses on each loop iteration.
test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py Adds unit tests covering stale-value clearing on re-entry and preservation when a new answer is supplied.

Comment thread agent/component/fillup.py Resolved
@yuzhichang
yuzhichang self-requested a review July 10, 2026 08:15

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 10, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 10, 2026
@ondery
ondery force-pushed the fix/userfillup-loop-wait-each-iteration branch from 78370d8 to d4011a7 Compare July 10, 2026 12:25
@codecov

codecov Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (eca8e87) to head (7656e2e).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16794   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

ondery added 2 commits July 10, 2026 17:55
A UserFillUp (Await Response) node inside a Loop only paused on the first iteration. Because the component object is reused across iterations, its form field values persisted from the previous answer, so the canvas wait-check saw them as satisfied and skipped the pause on later iterations. Clear the retained form values when a UserFillUp is entered without a fresh user answer so it waits for input again on every iteration.
Optional file inputs are treated as satisfied when empty, so clearing them on re-entry would not force a re-prompt and would only drop a previously uploaded file. Skip them in _clear_form_values to avoid unexpected data loss.
@ondery
ondery force-pushed the fix/userfillup-loop-wait-each-iteration branch from 3565799 to 7656e2e Compare July 10, 2026 14:56
@yuzhichang
yuzhichang merged commit 4060cd1 into infiniflow:main Jul 10, 2026
4 checks passed
ondery added a commit to ondery/ragflow that referenced this pull request Jul 10, 2026
A single-input UserFillUp (Await Response) node auto-filled its field from
the initial user query (sys.query) and continued without pausing, unlike
multi-input forms which correctly wait. The initial-query consumption is
only meaningful for the entry Begin node, so restrict it to Begin and make
every mid-flow Await Response pause for a fresh user response.

Rebased onto main (which already contains the Loop-iteration fix infiniflow#16794);
the Begin-based tests are combined with the existing loop tests.
@ondery
ondery deleted the fix/userfillup-loop-wait-each-iteration branch July 10, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer 🌈 python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants