Skip to content

fix: 不再把 reasoning_content 拼接到模型输出前面 - #64

Open
li-xiu-qi wants to merge 1 commit into
stepfun-ai:mainfrom
li-xiu-qi:fix/ask-llm-reasoning-content
Open

fix: 不再把 reasoning_content 拼接到模型输出前面#64
li-xiu-qi wants to merge 1 commit into
stepfun-ai:mainfrom
li-xiu-qi:fix/ask-llm-reasoning-content

Conversation

@li-xiu-qi

@li-xiu-qi li-xiu-qi commented Jun 16, 2026

Copy link
Copy Markdown

问题

Fixes #62

用 Chat Completions 接口跑云端推理模型(比如 step-3.7-flash)时,parser 在第一步就挂了:

ValueError: ui_action must contain 'action' or 'action_type'. Got keys: ['cot']

根因

ask_llm_v2.py 检测到 API 响应里的 reasoning_content,就把它包成一个 <think> 块拼到模型 content 前面:

result = "<think>" + reasoning + "</think>" + "\n" + llm_content

但模型的 content 本身已经带了 <THINK> 标签(parser 提示词要求的),这样就叠成了两层:

<think>API 返回的 reasoning_content</think>      ← ask_llm_v2.py 拼上去的
<THINK>模型自己的思考</THINK>                    ← 来自模型 content
explain:...  action:CLICK  point:500,300  ...    ← parser 真正要的这段

parser 的 str2action()split("</THINK>")[1] 取键值段,取到的是第一个 </THINK> 之后的内容,也就是第二层 THINK 的正文,而不是动作参数。

三接口对比

接口 推理内容位置 是否两层 THINK
Chat Completions reasoning_content 字段,被 ask_llm_v2.py 拼接
Messages (Anthropic) 独立的 thinking 类型块
Responses 独立的 reasoning 类型 output item

模型的 content 永远只有一层 <THINK>。问题完全出在 ask_llm_v2.py 的处理上。

修复

不再把 reasoning_content 拼到结果前面。保留它做调试日志,直接返回 content 本身。content 已经符合 <THINK>...</THINK>\texplain:...\taction:...\tsummary:... 的格式。

只改了 tools/ask_llm_v2.py 一个文件(19 增 26 删)。

验证

step-3.7-flash 控制真机(iQOO Z9 Turbo+)测过:

任务 步数 结果
打开 设置 > 关于手机 > 读取型号信息 5 步 成功完成
打开微信 > 找到并进入指定群聊 5 步 成功完成

两个任务在修复前都会在第一步 parser 报错,修复后都跑通了。

When using cloud reasoning models (e.g. step-3.7-flash) via Chat Completions
API, ask_llm_v2.py was wrapping reasoning_content as a <think> block and
prepending it to the model's content output. But the model's content already
contains <THINK> tags (required by the parser prompt), so this created two
layers of THINK tags:

  <think>reasoning_content from API field</think>
  <THINK>model's own THINK from prompt</THINK>
  explain:...  action:CLICK  point:500,300  summary:...

The parser's str2action() uses split('</THINK>')[1] to extract key-value
pairs, which grabbed the second THINK block text instead of the actual
action parameters, causing:
  ValueError: ui_action must contain 'action' or 'action_type'

Fix: log reasoning_content for debugging but return model's content as-is.
The content already follows the expected format:
  <THINK>...</THINK>\texplain:...\taction:...\tsummary:...

Verified with step-3.7-flash controlling Android device:
- Task: open WeChat and find specific group chat
- Result: 5 steps, completed successfully (was failing at step 1 before fix)
@li-xiu-qi li-xiu-qi changed the title fix: stop prepending reasoning_content to model output fix: 不再把 reasoning_content 拼接到模型输出前面 Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser fails when using step-3.7-flash via Chat Completions API

1 participant