Fix: Resolve Critical Build and Runtime Errors for Modern Environments #416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses several critical dependency and runtime bugs that prevent the XAgent project from building and running successfully on modern development environments, particularly on macOS with ARM64 architecture (Apple Silicon) and recent Linux distributions.
These changes should significantly improve the out-of-the-box experience for new contributors and users.
The Problem
On a clean clone of the repository, the setup process fails at multiple stages:
ToolServerNodeDocker image fails to build due to:openjdk-17-jdk-headlesspackage being unavailable in the base image's package repositories.playwright install-depscommand failing because it tries to install outdated or unavailable system dependencies.xagent-mysqlcontainer consistently fails to start on ARM64 platforms due to an incompatible image or configuration.run.pyscript fails due to:pinecone-clientdependency, which now intentionally throws an exception.openailibrary (v1.x) and the agent's parsing logic, which expects the legacyopenai<1.0response format. This results in aKeyError: 0during JSON parsing.ValueError: max_workers must be greater than 0when the web search tool returns an empty list of results.KeyError: 0parsing error in the "reflection" step, caused by the code trying to parse an object that was already a dictionary.The Solution
This PR implements the following fixes to address these issues:
Dockerfile Updates (
ToolServer/Dockerfile.node):openjdk-21-jre-headless, which is available in the base image.playwright install-depscommand non-fatal by appending|| true. This allows the build to succeed even if some optional browser dependencies are missing, which doesn't affect the core functionality.Docker Compose Update (
docker-compose.yml):mysqlimage with the officialmysql/mysql-server:latestimage.platform: linux/amd64and a more robust health check to ensure the MySQL container starts reliably across different architectures.Dependency Fixes (
requirements.txt):openai==0.28.1andhttpx==0.23.0. This is the "magic combination" that is compatible with the agent's internal parsing logic for OpenAI function calls.pinecone-clientwithpinecone==3.1.0.Runtime Code Patches:
XAgent/XAgent/function_handler.py: Added a check to ensurelen(result) > 0before creating aThreadPoolExecutorto prevent theValueError.XAgent/XAgent/workflow/plan_exec.py: Fixed the primary parsing bug by removing the redundantjson5.loads()call, directly using the dictionary object from the OpenAI response.XAgent/XAgent/workflow/reflection.py: Applied the same fix to the reflection step, resolving the final runtime crash.How to Test This Fix
docker compose up --build -d. The build process and container startup should now complete successfully without any errors.python3 -m venv .venv source .venv/bin/activateassets/config.yml.python run.py --task "What is the capital of France and what is the weather there now?"