From a25f7b8a297a7fb41eae51cb6a1d789a6a1a8350 Mon Sep 17 00:00:00 2001 From: Jiaqing Liang Date: Mon, 2 Feb 2026 15:22:05 +0800 Subject: [PATCH] feat: improve system compatibility and increase stdout buffer limit to 8000 --- agentapp.py | 3 ++- assets/tools_schema.json | 2 +- ga.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/agentapp.py b/agentapp.py index 32836cc..735eec1 100644 --- a/agentapp.py +++ b/agentapp.py @@ -8,7 +8,8 @@ import streamlit as st import time, json, re with open('assets/tools_schema.json', 'r', encoding='utf-8') as f: - TOOLS_SCHEMA = json.load(f) + TS = f.read() + TOOLS_SCHEMA = json.loads(TS if os.name == 'nt' else TS.replace('powershell', 'bash')) st.set_page_config(page_title="Cowork", layout="wide") diff --git a/assets/tools_schema.json b/assets/tools_schema.json index 37c1862..971ee40 100644 --- a/assets/tools_schema.json +++ b/assets/tools_schema.json @@ -1,7 +1,7 @@ [ {"type": "function", "function": { "name": "code_run", - "description": "针对 Windows 优化的双模态代码执行器。优先使用python,仅在必要系统操作时使用 powershell。注意:执行的代码必须放在在回复正文中,以 ```python 或 ```powershell 代码块的形式。严禁在代码中硬编码大量数据,如有需要应通过文件读取。", + "description": "代码执行器。优先使用python,仅在必要系统操作时使用 powershell。注意:执行的代码必须放在在回复正文中,以 ```python 或 ```powershell 代码块的形式。严禁在代码中硬编码大量数据,如有需要应通过文件读取。", "parameters": {"type": "object", "properties": { "type": {"type": "string", "enum": ["python", "powershell"], "description": "执行环境类型,默认为 python。", "default": "python"}, "timeout": {"type": "integer", "description": "执行超时时间(秒),默认 60。", "default": 60}, diff --git a/ga.py b/ga.py index 7dfe6a4..68e41cb 100644 --- a/ga.py +++ b/ga.py @@ -71,7 +71,7 @@ def code_run(code: str, code_type: str = "python", timeout: int = 60, cwd: str = if process.stdout: threading.Thread(target=process.stdout.close, daemon=True).start() return { "status": status, - "stdout": smart_format(stdout_str, max_str_len=4000, omit_str='\n[omitted long output]\n'), + "stdout": smart_format(stdout_str, max_str_len=8000, omit_str='\n[omitted long output]\n'), "exit_code": exit_code } except Exception as e: