iflytek/astron-agent · warning · CotFormatIncorrectExc
无效的推理格式,Action字段不完整
Error message
无效的推理格式,Action字段不完整
What it means
parse_cot_step requires both an Action marker and an Action Input marker, in that order, to consider a step a tool-call step. If either marker is missing, or Action appears after Action Input, it raises CotFormatIncorrectExc '无效的推理格式,Action字段不完整' (invalid reasoning format, Action field incomplete). This enforces ordering in the ReAct protocol emitted by the model.
Solutions
- Check and increase max_tokens so the step is not truncated before Action Input completes.
- Reinforce the exact marker keywords (Action / Action Input) in the system prompt with a full example step.
- Add a retry that reprompts the model with CotFormatIncorrectExc message when parsing fails.
- If the model tends to answer directly, ensure tool-use instructions state that non-final answers MUST contain both fields.
Example fix
// before (model output)
Action: search_weather
// after
Action: search_weather
Action Input: {"city": "合肥"} Defensive patterns
Strategy: retry
Try / catch
for attempt in range(2):
try:
step = await runner.parse_cot_step(content)
break
except CotFormatIncorrectExc as e:
content = await reprompt_with_format_error(e, messages)
else:
raise CotFormatIncorrectExc(str_format_instructions) Prevention
- Increase max_tokens to avoid truncation mid-step.
- Keep prompt marker examples byte-identical to PROTOCOL_MARKERS.
- Log raw step_content on parse failure to catch near-miss markers.
When it happens
Trigger: The LLM step text omits 'Action Input:' after 'Action:', omits 'Action:' entirely, or writes Action Input before Action; markers are matched via PROTOCOL_MARKERS regexes on step_content.
Common situations: Model truncation (max_tokens cut mid-step); model answering directly without the tool-call scaffold; translated/paraphrased marker words ('使用工具' instead of 'Action'); prompt examples inconsistent with the parser's markers.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/10bae85b9690a6d1.
Report an issue: GitHub.
Appendix: source
Thrown at core/agent/engine/nodes/cot/cot_runner.py:180
def _marker_presence(self, step_content: str) -> dict[str, bool]:
return {
marker: self._find_marker(step_content, marker) is not None
for marker in PROTOCOL_MARKERS
}
async def _parse_action_and_input(
self, step_content: str
) -> tuple[str, str, dict[str, Any]]:
"""解析 action、action_input 和 thought"""
action_marker = self._find_marker(step_content, "action")
action_input_marker = self._find_marker(step_content, "action_input")
if (
action_marker is None
or action_input_marker is None
or action_marker.end() > action_input_marker.start()
):
raise cot_exc.CotFormatIncorrectExc("无效的推理格式,Action字段不完整")
thought = ""
thought_marker = self._find_marker(step_content, "thought")
if thought_marker is not None and thought_marker.end() <= action_marker.start():
thought = step_content[thought_marker.end() : action_marker.start()].strip()
action = step_content[action_marker.end() : action_input_marker.start()].strip()
action = action.strip("`*_")
if not await self.is_valid_plugin(action):
raise cot_exc.CotFormatIncorrectExc(f"无效的插件名称'{action}'")
action_input_end = len(step_content)
observation_marker = self._find_marker(step_content, "observation")
if (
observation_marker is not None
and observation_marker.start() >= action_input_marker.end()
):View on GitHub (pinned to 5e758547a8)