VRSEN / agency-swarm

The only reliable agent framework built on top of the latest OpenAI Assistants API.
https://vrsen.github.io/agency-swarm/
MIT License
2.05k stars 537 forks source link

Genesis needs human-interaction when it is not needed. #115

Closed ZanzyTHEbar closed 1 week ago

ZanzyTHEbar commented 2 months ago

image

First off, i love genesis. I am a senior developer, and having an automation tool to setup the pipeline infrastructure is a fantastic move imo. Well done.

However, i am having a bit of an issue with it, as in my scenerios gensis needs constant babying. What do i mean:

The genesis outputs files such as:

<!-- instructions.md -->
# Plant Intelligence Agent (PIA) Instructions

You are tasked with the identification of plants, and the detection of diseases and pests using advanced machine learning techniques within the GardenGenius agency. Utilize the Retrieval Augmented Generation (RAG) workflow integrated with both real-time and historical data.

### Primary Instructions:
1. Use advanced machine learning toolkits for image and pattern recognition to analyze plant health.
2. Leverage databases for long-term memory that helps to track and understand user preferences and plant health history.
3. Communicate findings effectively to the Director of Garden Operations (DGO) for appropriate actions.
4. Stay updated with the latest advancements in AI and plant sciences to improve detection and identification processes.
# __init__.py
# These first two are correct and modified by me, the human
from DirectorOfGardenOperations import DirectorOfGardenOperations
from EnvironmentAnalysisAgent import EnvironmentAnalysisAgent

# This is the format for all newly created agents, before human intervention
from .plantintelligenceagent import PlantIntelligenceAgent

As you can see, the name for the agents containing folder is derived from the markdown instructions - however there are spaces in the name in the markdown but not in the python file or folder names (as it should be). This causes genesis to fail to discover the agent directory and create a false import statement. After resolving the import and the name formatting for the containing folder - I can proceed by telling genesis that the directory issue is solved. However, in multi-tenant applications with lots of agents, this is not a sustainable or automated workflow and requires constant babying.

Here is the project folder structure for reference, as generated by genesis: image

VRSEN commented 2 months ago

Thank you for opening this. Could you please test again and let me know if it works? I prefer folder names for agents in CamelCase without spaces.

ZanzyTHEbar commented 1 month ago

Hey! Thanks for responding so quickly. I will test this and get back to you :)

ZanzyTHEbar commented 1 month ago

It seems to be working, but now all of my projects fail to create tools:

CreateTool ⚙️ Function Output
Error: Request timed out.

Then it continues to try until i get this:

Traceback (most recent call last):
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 142, in get_completion
    self._submit_tool_outputs(tool_outputs, event_handler)
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 254, in _submit_tool_outputs
    with self.client.beta.threads.runs.submit_tool_outputs_stream(
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 444, in __enter__
    self.__stream = self.__api_request()
                    ^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1232, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 921, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1012, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Runs in status "expired" do not accept tool outputs.', 'type': 'invalid_request_error', 'param': None, 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/verdant_virtuoso/.venv/bin/agency-swarm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/cli.py", line 51, in main
    agency.run_demo()
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 554, in run_demo
    self.get_completion_stream(message=text, event_handler=TermEventHandler, recipient_agent=recipient_agent)
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 175, in get_completion_stream
    res = self.main_thread.get_completion_stream(message=message,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 54, in get_completion_stream
    return self.get_completion(message,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 161, in get_completion
    tool_outputs[i]["tool_call_id"] = tool_call.id
    ~~~~~~~~~~~~^^^
IndexError: list index out of range

Ive tried multiple times, my openai account is fine, i havent reached any rate limits and i have credits on the account.

slowell commented 1 month ago

It seems to be working, but now all of my projects fail to create tools:

CreateTool ⚙️ Function Output
Error: Request timed out.

Then it continues to try until i get this:

Traceback (most recent call last):
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 142, in get_completion
    self._submit_tool_outputs(tool_outputs, event_handler)
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 254, in _submit_tool_outputs
    with self.client.beta.threads.runs.submit_tool_outputs_stream(
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/lib/streaming/_assistants.py", line 444, in __enter__
    self.__stream = self.__api_request()
                    ^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1232, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 921, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/openai/_base_client.py", line 1012, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Runs in status "expired" do not accept tool outputs.', 'type': 'invalid_request_error', 'param': None, 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/verdant_virtuoso/.venv/bin/agency-swarm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/cli.py", line 51, in main
    agency.run_demo()
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 554, in run_demo
    self.get_completion_stream(message=text, event_handler=TermEventHandler, recipient_agent=recipient_agent)
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/agency/agency.py", line 175, in get_completion_stream
    res = self.main_thread.get_completion_stream(message=message,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 54, in get_completion_stream
    return self.get_completion(message,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/verdant_virtuoso/.venv/lib/python3.11/site-packages/agency_swarm/threads/thread.py", line 161, in get_completion
    tool_outputs[i]["tool_call_id"] = tool_call.id
    ~~~~~~~~~~~~^^^
IndexError: list index out of range

Ive tried multiple times, my openai account is fine, i havent reached any rate limits and i have credits on the account.

Having same issue. Had a few successfully created but haven't been able to complete a full agency.

VRSEN commented 1 month ago

Thanks for the feedback, guys. This can happen if you are creating or running an extremely complex agency where a run timeout occurs before agents have finished execution. I added some error handling for this; let me know if it helps. Hopefully, openai will add controls for the run timeout later.

slowell commented 1 month ago

Will take a look! Thanks for the quick response.

ZanzyTHEbar commented 1 month ago

I have tested, the same issue still persists - however it is happening less often. I can now create tools again - as long as I keep the scope barebones and extremely simple. Which is a shame, but understandable.

As a side note - something like plandex.ai is honestly performing better than Genesis and Devid at this point in time. I have switched over to plandex for the time being when I need to generate projects and code (Devid is unusable in its current state), I then use Plandex to generate my tools for Agency Swarm.

Perhaps there is something in the code-base that is making it more stable and reliable? I took a peruse through it and it seems to have much more robust strategies and error handling mechanisms. It even uses a summary feature to chunk messages to the AI when a file/task is too long for the context window/stream response of the LLM. It summarizes and chunk to and from the AI. This feature alone has totally eliminated the request-time issue, as well as being able to modify files it has already created.

Stavros963 commented 1 month ago

Dear All,

First you should know I am no coding expert, not at all, so be nice with the way I present things! Second, I find Genesis an incredibly clever idea and I will persist until it works. I will. Persist.

Now, in my way, I believe I encounter the same problem as mentioned by the others:

a) I have been able to run up to the end some agency examples such as MetaMarkAgency.

b) When I try to build my own agency, it crashes 100% of the time. And I tried numerous times. And I tried very simple agencies. Open ai API correct and everything.

Based on the following, it seems to me that it has to do with the Create Tool function that should imperatively create tools in a sequential way. Look below for an example:

CreateTool ⚙️ Function Output Error: Function CreateTool is already called. You can only call this function once at a time. Please wait for the previous call to finish before calling it again.

ToolCreator 🗣️ @AgentCreator The PDFAnalysisTool for the AnalysisAgent has been successfully created. It can open and read PDF files, extract text, as well as identify important information such as tables and headings.

However, there was an issue with creating the TextExtractionTool and the DataAnalysisTool simultaneously with the PDFAnalysisTool. I will now initiate the creation of these remaining tools one by one.

ToolCreator 🗣️ @AgentCreator It appears that there are persistent issues with the system timing out when attempting to create the tools for the AnalysisAgent. I will escalate this issue for further assistance to resolve the system timeouts and ensure the tools are created successfully. Please bear with us as we address this matter.

Then what happens is a long series of timeouts (of course I do not know if it is related to the above), then it crashes.

Basically the same problem appears, whatever tools the ToolCreator is processing, in every attempt I make, of course not only related to an AnalysisAgent using PDFs. So my non-expert point of view is that there is something to be adapted within the ToolCreator script.

Your opinion?

With my best regards!

VRSEN commented 1 month ago

There was a small bug with the message history inside this tool, which could have been causing the timeout issue. Please install from the main branch and try again, @Stavros963

Stavros963 commented 1 month ago

There was a small bug with the message history inside this tool, which could have been causing the timeout issue. Please install from the main branch and try again, @Stavros963

Thank you for your quick answer!... As I mentioned, I am no coding specialist. Would you be so kind to indicate what you mean by "main branch"?... Please do not laugh at this candid question. And then, I can tell you, I will use it and share, and provide feedback.

All the best on your side!

Stavros963 commented 1 month ago

Thank you David,

I will find a way as a non-specialist to install from the branch again and make it work. To me, coming from a totally different environment and industry, the experiment is not to install agency-swarm but to use it as to build applicable and lucrative solutions, beyond the « usual » SEO, Website builder et al. I will keep you posted if you agree!

With my best regards from Switzerland,

Stavros

Le 7 mai 2024 à 08:44, Arsenii Shatokhin @.***> a écrit :

There was a small bug with the message history inside this tool, which could have been causing the timeout issue. Please install from the main branch and try again, @Stavros963 https://github.com/Stavros963 — Reply to this email directly, view it on GitHub https://github.com/VRSEN/agency-swarm/issues/115#issuecomment-2097564035, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDD7GWQAF2HY4AHYF5V4BWTZBBZ4TAVCNFSM6AAAAABG6D345CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXGU3DIMBTGU. You are receiving this because you were mentioned.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity. Please upgrade to the latest version and test it again.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale. If the issue still persists, please reopen.