{"record":{"id":"10bae85b9690a6d1","repo":"iflytek/astron-agent","slug":"action","errorCode":null,"errorMessage":"无效的推理格式，Action字段不完整","messagePattern":"无效的推理格式，Action字段不完整","errorType":"exception","errorClass":"CotFormatIncorrectExc","httpStatus":null,"severity":"warning","filePath":"core/agent/engine/nodes/cot/cot_runner.py","lineNumber":180,"sourceCode":"\n    def _marker_presence(self, step_content: str) -> dict[str, bool]:\n        return {\n            marker: self._find_marker(step_content, marker) is not None\n            for marker in PROTOCOL_MARKERS\n        }\n\n    async def _parse_action_and_input(\n        self, step_content: str\n    ) -> tuple[str, str, dict[str, Any]]:\n        \"\"\"解析 action、action_input 和 thought\"\"\"\n        action_marker = self._find_marker(step_content, \"action\")\n        action_input_marker = self._find_marker(step_content, \"action_input\")\n        if (\n            action_marker is None\n            or action_input_marker is None\n            or action_marker.end() > action_input_marker.start()\n        ):\n            raise cot_exc.CotFormatIncorrectExc(\"无效的推理格式，Action字段不完整\")\n\n        thought = \"\"\n        thought_marker = self._find_marker(step_content, \"thought\")\n        if thought_marker is not None and thought_marker.end() <= action_marker.start():\n            thought = step_content[thought_marker.end() : action_marker.start()].strip()\n\n        action = step_content[action_marker.end() : action_input_marker.start()].strip()\n        action = action.strip(\"`*_\")\n\n        if not await self.is_valid_plugin(action):\n            raise cot_exc.CotFormatIncorrectExc(f\"无效的插件名称'{action}'\")\n\n        action_input_end = len(step_content)\n        observation_marker = self._find_marker(step_content, \"observation\")\n        if (\n            observation_marker is not None\n            and observation_marker.start() >= action_input_marker.end()\n        ):","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/agent/engine/nodes/cot/cot_runner.py#L162-L198","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (model output)\nAction: search_weather\n// after\nAction: search_weather\nAction Input: {\"city\": \"合肥\"}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        step = await runner.parse_cot_step(content)\n        break\n    except CotFormatIncorrectExc as e:\n        content = await reprompt_with_format_error(e, messages)\nelse:\n    raise CotFormatIncorrectExc(str_format_instructions)","preventionTips":["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."],"tags":["llm","cot","prompt-protocol","agent"],"backgroundTag":"invalid-argument-format","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}