fix(ga): web_execute_js 归一化非str的script参数,避免AttributeError中断agent循环
This commit is contained in:
1 parent
b70079dce7
commit
545017cea0
1 file changed
+2
-1
@@ -353,7 +353,8 @@ class GenericAgentHandler(BaseHandler):
|
||||
def do_web_execute_js(self, args, response):
|
||||
'''web情况下的优先使用工具,执行任何js达成对浏览器的*完全*控制。支持将结果保存到文件供后续读取分析。'''
|
||||
script = args.get("script", "") or self._extract_code_block(response, "javascript")
|
||||
if not script: return StepOutcome("[Error] Script missing. Use ```javascript block or 'script' arg.", next_prompt="\n")
|
||||
if not isinstance(script, str): script = json.dumps(script, ensure_ascii=False, default=json_default) if isinstance(script, (dict, list)) else str(script)
|
||||
if not script or not script.strip(): return StepOutcome("[Error] Script missing. Use ```javascript block or 'script' arg.", next_prompt="\n")
|
||||
abs_path = self._get_abs_path(script.strip())
|
||||
if os.path.isfile(abs_path):
|
||||
with open(abs_path, 'r', encoding='utf-8') as f: script = f.read()
|
||||
|
||||
Reference in new issue
Block a user