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
Allow to use async tools within the task pipeline #550
base: main
Are you sure you want to change the base?
Conversation
Interesting, would love to hear more about the use case that prompted this given the |
link for reference: https://docs.crewai.com/core-concepts/Tasks/#asynchronous-execution |
Wow thanks for your promptness. One of the things we wanted to do was to give the agents the ability to talk to the users to ask clarifying questions directly using the websockets that we provide them. So we made a tool that allows the agent to ask questions and wait for a response from the user. But we don't want to exit the task pipeline since that will take a little longer + more openai api calls. This is also helpful for some tools where the agent prepares a draft email for instance, but wants to wait for the user confirmation before proceeding to send it. The tool has to await a response before proceeding - so this async allows for that. Its not just for the task to be async, but rather the Tools to be async. Ideally we could just make the the default kickoff with the async code that I added - since that can be used with async tool and regular old sync tools. So far in our product, we've been doing exactly that - so it saves us a lot of redundancy. But for that, every other crewai user will have to change |
Oh got it, something more complex then the current human input on execution? basically that but over sockets. |
Yes exactly - we can do as many new tasks while waiting for a response on a previous task. I see that the human input was added recently - you guys are working at 🚀 speed - I'll take a look at it deeper. But the basic idea of having async tools remains the same - opening up the crew to use a lot more complex tools - including taking over sockets / performing non-blocking api requests / etc. |
got it! Any chance you would make this socket human input tool public? :D no pressure but I'd love to add it to crewai-tool or find a way to bring them into the main package somehow |
This is a big change so I'll test is a little myself before merging just in case but I like the problem it aims to solve |
Amazing - appreciate any feedback on it and ideas on how to make the code a little less redundant - since most of it is just about adding an await in the right places. And detecting whether the tool is a coroutine or not and then deciding to use _run or await _run. |
And certainly, I'll try and add the socket human input in a following PR but that part is a little more coupled with my current infra setup haha so could be tough. But I agree, would be a great addition to the crewai toolkit |
I've added a quick |
Hello! I just came across this MR. I found out about CrewAI from a video on agentic workflow. I'm also interested in being able to intervene during a workflow. I prefer that the AI asks me questions, probes me so that I myself can be an agent influencing the final outcome. Have you considered using messaging tools like Slack, Discord, or Telegram? I assume your websocket tool is homemade? Would a workflow that uses a database to save its state to resume its process later be an interesting topic to explore for CrewAI? |
Yep the reason I wanted to add async tools was so that I can connect my agents to websockets that connect to Slack + RetellAI voice. So I give each agent a tool |
I think this native support for async will be really nice to have considering most of the LLM already supports this. I was hoping to integrate CrewAI has the Agent framework for Sage https://github.com/thehapyone/Sage Alternatively, asyncify is one hack package that can be used to create a sync version of this |
Introduces a way to use async tools seamlessly within a crew task.