Repository navigation
Fix: path-aware reset in canvas.run() to preserve cross-run outputs - #14600
Conversation
When an agent workflow contains multiple UserFillUp pause points,
canvas.run() previously called reset(True) on ALL components at the
start of each run. This cleared outputs from components that had
already completed in prior runs, causing downstream references
(e.g. {Agent:XXX@content}) to resolve to None.
This fix builds a set from self.path (which tracks the current
execution path) and only resets components that are part of that
path. Components completed in earlier runs retain their outputs,
allowing cross-run variable references to work correctly.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughThe Canvas.run method now resets only components currently in the active execution path instead of unconditionally resetting all components. This optimization narrows the scope of component reset operations by building a set of active path IDs and conditionally applying reset logic to matching components. ChangesCanvas Component Reset Optimization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
agent/canvas.py (1)
382-385: ⚡ Quick winAdd debug logging for the new path-scoped reset flow.
The new branch at Line 382–Line 385 changes reset semantics but emits no trace, which makes resume-path state issues hard to debug. Please log task ID, path size, and reset component IDs/count at debug level.
Proposed patch
path_set = set(self.path) + logging.debug( + "Canvas.run path-scoped reset: task_id=%s path_size=%d", + self.task_id, + len(path_set), + ) for k, cpn in self.components.items(): if k in path_set: self.components[k]["obj"].reset(True) + logging.debug( + "Canvas.run reset complete: task_id=%s reset_count=%d", + self.task_id, + len(path_set), + )As per coding guidelines, "**/*.py: Add logging for new flows".
🤖 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/canvas.py` around lines 382 - 385, Add debug-level logging around the new path-scoped reset branch: before computing path_set/logging, capture task id (self.task_id or similar), path size (len(self.path)), and then collect the list/count of component ids that will be reset (those k in self.components intersecting path_set). Log a concise debug message including task id, path size, reset count and component ids right before calling self.components[k]["obj"].reset(True) (or immediately after identifying them) so resume-path state changes are traceable; use the existing logger instance used elsewhere in this class (e.g., self.logger or the module logger) to maintain consistent logging.
🤖 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/canvas.py`:
- Around line 382-385: Add debug-level logging around the new path-scoped reset
branch: before computing path_set/logging, capture task id (self.task_id or
similar), path size (len(self.path)), and then collect the list/count of
component ids that will be reset (those k in self.components intersecting
path_set). Log a concise debug message including task id, path size, reset count
and component ids right before calling self.components[k]["obj"].reset(True) (or
immediately after identifying them) so resume-path state changes are traceable;
use the existing logger instance used elsewhere in this class (e.g., self.logger
or the module logger) to maintain consistent logging.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14600 +/- ##
=======================================
Coverage 94.16% 94.16%
=======================================
Files 10 10
Lines 703 703
Branches 112 112
=======================================
Hits 662 662
Misses 25 25
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…nfiniflow#14600) ## Summary - When an agent workflow has multiple `UserFillUp` pause points, `canvas.run()` calls `reset(True)` on **all** components at the start of each run. This clears outputs from components that completed in prior runs, so downstream references like `{Agent:XXX@content}` resolve to `None`. - This fix only resets components on the **current execution path** (`self.path`), preserving outputs from previously completed components. ## Problem In a multi-step agent (e.g. draft email → user confirms → send email): 1. First `run()`: Agent drafts content, UserFillUp pauses for user input → Agent output is saved 2. Second `run()`: User submits input, but `reset(True)` clears **all** components including the Agent that already completed 3. Email component references `{Agent:XXX@content}` → gets `None` instead of the draft This affects **all** agents that reference upstream component outputs after a UserFillUp pause point. ## Fix ```python # Before: reset ALL components for k, cpn in self.components.items(): self.components[k]["obj"].reset(True) # After: only reset components on current execution path path_set = set(self.path) for k, cpn in self.components.items(): if k in path_set: self.components[k]["obj"].reset(True) ``` `self.path` already tracks the current execution path. For agents without UserFillUp (single run), `path` contains all components, so behavior is unchanged. ## Test plan - [x] Agent with single UserFillUp: outputs from prior components are preserved after resume - [x] Agent with multiple UserFillUp: each resume preserves all previously completed outputs - [x] Agent without UserFillUp: behavior unchanged (all components in path, all reset) - [x] Webhook-triggered agents: unaffected (path includes all components on first run) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: wanghualoong <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
…nfiniflow#14600) ## Summary - When an agent workflow has multiple `UserFillUp` pause points, `canvas.run()` calls `reset(True)` on **all** components at the start of each run. This clears outputs from components that completed in prior runs, so downstream references like `{Agent:XXX@content}` resolve to `None`. - This fix only resets components on the **current execution path** (`self.path`), preserving outputs from previously completed components. ## Problem In a multi-step agent (e.g. draft email → user confirms → send email): 1. First `run()`: Agent drafts content, UserFillUp pauses for user input → Agent output is saved 2. Second `run()`: User submits input, but `reset(True)` clears **all** components including the Agent that already completed 3. Email component references `{Agent:XXX@content}` → gets `None` instead of the draft This affects **all** agents that reference upstream component outputs after a UserFillUp pause point. ## Fix ```python # Before: reset ALL components for k, cpn in self.components.items(): self.components[k]["obj"].reset(True) # After: only reset components on current execution path path_set = set(self.path) for k, cpn in self.components.items(): if k in path_set: self.components[k]["obj"].reset(True) ``` `self.path` already tracks the current execution path. For agents without UserFillUp (single run), `path` contains all components, so behavior is unchanged. ## Test plan - [x] Agent with single UserFillUp: outputs from prior components are preserved after resume - [x] Agent with multiple UserFillUp: each resume preserves all previously completed outputs - [x] Agent without UserFillUp: behavior unchanged (all components in path, all reset) - [x] Webhook-triggered agents: unaffected (path includes all components on first run) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: wanghualoong <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
UserFillUppause points,canvas.run()callsreset(True)on all components at the start of each run. This clears outputs from components that completed in prior runs, so downstream references like{Agent:XXX@content}resolve toNone.self.path), preserving outputs from previously completed components.Problem
In a multi-step agent (e.g. draft email → user confirms → send email):
run(): Agent drafts content, UserFillUp pauses for user input → Agent output is savedrun(): User submits input, butreset(True)clears all components including the Agent that already completed{Agent:XXX@content}→ getsNoneinstead of the draftThis affects all agents that reference upstream component outputs after a UserFillUp pause point.
Fix
self.pathalready tracks the current execution path. For agents without UserFillUp (single run),pathcontains all components, so behavior is unchanged.Test plan
🤖 Generated with Claude Code