Ironclad / rivet

The open-source visual AI programming environment and TypeScript library
https://rivet.ironcladapp.com
MIT License
2.71k stars 237 forks source link

[Bug]: Half of the items are being lost in loops if the final output is not passed over to the next iteration #441

Open remixer-dec opened 1 month ago

remixer-dec commented 1 month ago

What happened?

Here is a simple graph that loads a dataset and gets one item from it in each iteration

image

After all iterations, the subgraph call has 54 outputs, while the next node after it has only 27.

image

If we check the execution iteration 2, it is clear that the input of text node does not match the output of the subgraph. Connecting the text output to the loop data property and adding a break node temporary fixes this issue

What was the expected functionality?

Input values should match the output values of the nodes they're connected to, when data is transferred between nodes

Describe your environment

MacOS sonoma 14.4.1, Rivet version: app-v1.8.0

Relevant log output

No response

Relevant screenshots

No response

Code of Conduct

abrenneke commented 1 month ago

Right, this is one of the (currently unwritten) "rules of loops", in that every node needs to be part of the loop itself. So in this case, you want to connect the text node back to the loop controller so that it "knows" it's in the loop. You can't have any "dangling" things in loops, unfortunately.

remixer-dec commented 1 month ago

It is just weird that it does work, but half of the time, easy to forget about it. Some kind of warning would be nice if it is hard to fix. Well, as long as there is a workaround that gets the job done, it's not a big problem 😃