Loop

Three words

A loop repeats one step for each thing in a list you wrote.

The list is search, memory, and tools. Each pass hands the agent just that one word, and you get one line back.

Example

from praisonai import Agent, AgentFlow, Task, loop

processor = Agent(instructions="Repeat the input word, then two more words.")
step = Task(name="Processor", action="{{item}}", agent=processor)
flow = AgentFlow(
    steps=[loop(step, over="items")],
    variables={"items": ["search", "memory", "tools"]},
)
result = flow.start()
for item in result["steps"]:
    print(item["output"])

Try it Yourself

Example explained

  • over โ€” The name of the list to walk.
  • variables โ€” The lists and values the flow can read.
  • {{item}} โ€” The current element. The default name is item.

Reference: documentation