Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When the listen tag is same as the function name then the flow will stuck into infinite loop #1957

Open
mohd-jubair opened this issue Jan 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mohd-jubair
Copy link

Description

On using the crew flow,

let say I am routing in the middle, and the listener method which listen to the router method can run based on string and method instance.

so if the listening method name is same as the string then it will fall into infinite loop.

Steps to Reproduce

refer the code below

Expected behavior

Can identify the string and method name or it should restrict the this type of usage with some error.

Screenshots/Code snippets

class AnalysisState(BaseModel):
"""Analysis State class"""

state: int = 3

class CrewFlow(Flow[AnalysisState]):
"""Crew Flow class"""

@start()
def failure_research(self):
    """
    """
    print("Failure research crew will start here")

@listen(failure_research)
def failure_analysis(self):
    """
    """
    print("Failure analysis crew will start here")

@router(or_(failure_research, "looping"))
def what_next(self):
    """
    """
    print("Routing will start here")
    if self.state.state != 0:
        print("Looping here")
        self.state.state -= 1
        return "looping"
    return "compose_inference"

@listen("compose_inference")
def compose_inference(self):
    """
    """
    print("Inference crew will start here")

Operating System

Ubuntu 22.04

Python Version

3.10

crewAI Version

0.98.0

crewAI Tools Version

0.17.0

Virtual Environment

Venv

Evidence

Image

Possible Solution

Except with error! or have understanding on string and method naming

Additional context

Not a critical issue! as people know how to use it, it's good to fix to make the code more readable with same string that calling with different one.

@mohd-jubair mohd-jubair added the bug Something isn't working label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant