Skip to content

fix: loop component usage issue - #17028

Merged
yuzhichang merged 3 commits into
infiniflow:mainfrom
Haruko386:major
Jul 17, 2026
Merged

yuzhichang merged 3 commits into
infiniflow:mainfrom
Haruko386:major

Conversation

@Haruko386

Copy link
Copy Markdown
Member

Summary

As title

image

@Haruko386 Haruko386 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 17, 2026
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 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: fd07f7d2-a0c9-4d57-abdc-28d6bf73b3c9

📥 Commits

Reviewing files that changed from the base of the PR and between 76d5209 and dcd3f52.

📒 Files selected for processing (5)
  • internal/agent/canvas/node_body.go
  • internal/agent/canvas/scheduler.go
  • internal/agent/component/message.go
  • internal/agent/component/message_test.go
  • internal/service/agent.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • internal/service/agent.go
  • internal/agent/component/message_test.go
  • internal/agent/component/message.go
  • internal/agent/canvas/node_body.go
  • internal/agent/canvas/scheduler.go

📝 Walkthrough

Walkthrough

Loop execution now distinguishes explicit iteration caps from default safety limits, emits per-iteration streaming and lifecycle events, and forwards Canvas Message content through runtime emitters to SSE events.

Changes

Loop Canvas runtime

Layer / File(s) Summary
Loop execution semantics
internal/agent/workflowx/loop.go, internal/agent/workflowx/*test.go
Explicit iteration caps terminate normally on invoke and stream paths, while default safety caps still return ErrLoopMaxIterationsExceeded; lifecycle hooks wrap loop execution.
Canvas iteration lifecycle
internal/agent/canvas/loop_subgraph.go, internal/agent/canvas/node_body.go, internal/agent/canvas/scheduler.go, internal/agent/canvas/loop_semantics_test.go
Loop body wrappers and macro expansion pass component identifiers into state lifecycle callbacks, stream every iteration, and validate lifecycle events and state updates.
Canvas message delivery
internal/agent/runtime/context.go, internal/agent/component/message.go, internal/agent/component/message_test.go, internal/service/agent.go
Rendered Message content uses a Canvas emitter with agent fallback, and the service converts Canvas emissions into SSE message events.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CanvasLoop
  participant MessageComponent
  participant Runtime
  participant AgentService
  CanvasLoop->>MessageComponent: invoke Message for each iteration
  MessageComponent->>Runtime: emit rendered Canvas content
  Runtime->>AgentService: invoke Canvas message emitter
  AgentService->>AgentService: emit SSE message event
Loading

Possibly related PRs

Suggested labels: ☯️ refactor

Poem

I’m a bunny in the loop,
Counting hops from one to three.
Streams and messages bloom,
Lifecycle bells ring merrily.
Canvas sends each tick along—
Hop, hop, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only says "As title" and includes a screenshot, so it lacks the required summary and background context. Add a brief summary of the issue, the fix, and any relevant background or impact in the Summary section.
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the loop changes but too vague to identify the actual fix. Use a more specific title that names the main behavior change, such as loop iteration handling or message emission.
✅ Passed checks (2 passed)
Check name Status Explanation
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.

@Haruko386
Haruko386 marked this pull request as draft July 17, 2026 05:35
@Haruko386
Haruko386 marked this pull request as ready for review July 17, 2026 05:35
@Haruko386 Haruko386 added ci Continue Integration and removed ci Continue Integration labels Jul 17, 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

🧹 Nitpick comments (1)
internal/agent/canvas/loop_semantics_test.go (1)

172-175: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Describe the Go behavior this test actually exercises.

This comment references Python migration history and says a Message is emitted, but the test only counts stream chunks from counterLoopDSL. Remove it or state that Canvas loops expose one stream chunk per iteration.

As per coding guidelines, “keep package and documentation comments aligned with the current runtime path rather than migration history.”

🤖 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 `@internal/agent/canvas/loop_semantics_test.go` around lines 172 - 175, Update
the comment for TestLoop_StreamEmitsEveryIteration to describe the behavior
exercised by counterLoopDSL: Canvas loops expose one stream chunk per iteration.
Remove the Python migration reference and the claim about Message output, while
retaining the explanation that the loop uses every_iteration streaming rather
than returning only the final body result.

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.

Inline comments:
In `@internal/agent/workflowx/loop.go`:
- Around line 162-164: Update the WithLoopMaxIterations option logic around
maxIterations and maxIterationsSet to accept values only when n > 0; ignore zero
and negative inputs so the initialized default safety cap remains unchanged.

---

Nitpick comments:
In `@internal/agent/canvas/loop_semantics_test.go`:
- Around line 172-175: Update the comment for TestLoop_StreamEmitsEveryIteration
to describe the behavior exercised by counterLoopDSL: Canvas loops expose one
stream chunk per iteration. Remove the Python migration reference and the claim
about Message output, while retaining the explanation that the loop uses
every_iteration streaming rather than returning only the final body result.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e9cc87c-b2cc-47a9-8f00-bccc3b1e51aa

📥 Commits

Reviewing files that changed from the base of the PR and between 27d091b and ff02e22.

📒 Files selected for processing (13)
  • internal/agent/canvas/loop_semantics_test.go
  • internal/agent/canvas/loop_subgraph.go
  • internal/agent/canvas/node_body.go
  • internal/agent/canvas/scheduler.go
  • internal/agent/component/message.go
  • internal/agent/component/message_test.go
  • internal/agent/runtime/context.go
  • internal/agent/workflowx/loop.go
  • internal/agent/workflowx/loop_integration_test.go
  • internal/agent/workflowx/loop_options_test.go
  • internal/agent/workflowx/loop_test.go
  • internal/service/agent.go
  • internal/service/agent_run_e2e_test.go

Comment thread internal/agent/workflowx/loop.go Resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Haruko386 Haruko386 changed the title Fix: loop component usage issue fix: loop component usage issue Jul 17, 2026
@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit 344477f into infiniflow:main Jul 17, 2026
3 checks passed
@Haruko386
Haruko386 deleted the major branch July 20, 2026 01:40
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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants