修复parse_action函数:移除</answer>标签导致的语法解析错误 #347
Open
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.
问题描述(Problem Description)
使用 Open-AutoGLM 操作手机时,parse_action 函数解析 LLM 返回的动作指令(如 do(action="Tap", element=[811,188]))时,因指令字符串中混入 非 Python 语法标签,导致 ast.parse 解析失败,抛出 SyntaxError 异常,进而触发 ValueError 报错,无法正常执行点击等操作。
相关报错日志:
解决方案(Solution)
在 phone_agent/actions/handler.py 的 parse_action 函数中,新增字符串清理逻辑,解析前先处理无关字符: