fix: inline_eval exec() exception escaping crash; update schema description

This commit is contained in:
Jiaqing Liang
2026-04-17 16:06:13 +08:00
parent 47f106c8db
commit 0e3e602121
3 changed files with 5 additions and 4 deletions

View File

@@ -7,7 +7,7 @@
"type": {"type": "string", "enum": ["python", "powershell"], "description": "Code type", "default": "python"},
"timeout": {"type": "integer", "description": "in seconds", "default": 60},
"cwd": {"type": "string", "description": "Working directory, defaults to cwd"},
"inline_eval": {"type": "boolean", "description": "Only when usage is explicitly specified."}}}
"inline_eval": {"type": "boolean", "description": "DO NOT USE except explicitly specified."}}}
}},
{"type": "function", "function": {
"name": "file_read",

View File

@@ -7,7 +7,7 @@
"type": {"type": "string", "enum": ["python", "powershell"], "description": "代码类型", "default": "python"},
"timeout": {"type": "integer", "description": "执行超时时间(秒)", "default": 60},
"cwd": {"type": "string", "description": "工作目录,默认为当前工作目录"},
"inline_eval": {"type": "boolean", "description": "仅在明确要求时使用"}}}
"inline_eval": {"type": "boolean", "description": "不允许使用除非明确要求"}}}
}},
{"type": "function", "function": {
"name": "file_read",

1
ga.py
View File

@@ -290,6 +290,7 @@ class GenericAgentHandler(BaseHandler):
old_cwd = os.getcwd()
try:
os.chdir(cwd)
try:
try: result = repr(eval(code, ns))
except SyntaxError: exec(code, ns); result = ns.get('_r', 'OK')
except Exception as e: result = f'Error: {e}'