From decb5dcb6f25a2be7d92d33277edc444d2cf961b Mon Sep 17 00:00:00 2001 From: Tim Wang <38489718+wanghualoong@users.noreply.github.com> Date: Fri, 8 May 2026 15:10:15 +0800 Subject: [PATCH] Fix: path-aware reset in canvas.run() to preserve cross-run outputs (#14600) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 Co-authored-by: Claude Opus 4.6 --- agent/canvas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent/canvas.py b/agent/canvas.py index bd5f364187..ab6d0ba9ff 100644 --- a/agent/canvas.py +++ b/agent/canvas.py @@ -379,8 +379,10 @@ class Canvas(Graph): self.message_id = get_uuid() created_at = int(time.time()) self.add_user_input(kwargs.get("query")) + path_set = set(self.path) for k, cpn in self.components.items(): - self.components[k]["obj"].reset(True) + if k in path_set: + self.components[k]["obj"].reset(True) if kwargs.get("webhook_payload"): for k, cpn in self.components.items():