From 8f01103661ad1ac54625f9fa03948e0bfe3a0724 Mon Sep 17 00:00:00 2001 From: leyoonafr Date: Fri, 26 Jun 2026 15:58:48 +0800 Subject: [PATCH 1/7] feat: Extend concurrency-safe coverage for workspace file tools and enhance mutation path handling --- .../adapters/vibe/workspace_file_tool.py | 17 ++ .../core/tools/core/workspace_file_tool.py | 158 +++++++++------- src/xagent/core/workspace.py | 131 +++++++++----- .../agent/test_react_real_tool_concurrency.py | 111 +++++++++++- .../vibe/test_tool_metadata_concurrency.py | 34 ++++ .../tools/test_workspace_file_concurrency.py | 171 ++++++++++++++++++ 6 files changed, 517 insertions(+), 105 deletions(-) create mode 100644 tests/core/tools/test_workspace_file_concurrency.py diff --git a/src/xagent/core/tools/adapters/vibe/workspace_file_tool.py b/src/xagent/core/tools/adapters/vibe/workspace_file_tool.py index b900089de..393e0f750 100644 --- a/src/xagent/core/tools/adapters/vibe/workspace_file_tool.py +++ b/src/xagent/core/tools/adapters/vibe/workspace_file_tool.py @@ -174,86 +174,103 @@ def get_tools(self) -> List[FunctionTool]: self.read_file, name="read_file", description="Read file content in workspace. Accepts either file paths (e.g., 'filename.txt') or file_ids (e.g., 'abc-123-def'). Automatically detects input type. For large files, results may be truncated in model context; use start_line/end_line to inspect a specific 1-based inclusive line range instead of repeating the same full-file read.", + read_only=True, ), FileTool( self.write_file, name="write_file", description="Write file content in workspace. Use relative paths (e.g., 'filename.txt'), not absolute paths. Returns a FileRef with file_id, preview_url, download_url, and markdown_link.\n\nImportant: For HTML files, do not guess paths to uploaded files or files from other tasks. First call prepare_html_asset(file_id, html_path, alias) for every external image/CSS/JS asset, then use the returned html_src in the HTML.", + concurrency_safe=True, ), FileTool( self.prepare_html_asset, name="prepare_html_asset", description="Prepare an uploaded or registered file for use inside an HTML artifact. Pass the source file_id, the target HTML output path such as 'index.html' or 'reports/index.html', and an optional alias such as 'logo.png'. The tool copies the asset next to that HTML file under assets_subdir and returns html_src relative to the HTML file. Use html_src in , ,