{"record":{"id":"ec2b17a26be2f144","repo":"iflytek/astron-agent","slug":"cot-runner","errorCode":null,"errorMessage":"无效的推理格式，缺少必要的标识字段","messagePattern":"无效的推理格式，缺少必要的标识字段","errorType":"exception","errorClass":"CotFormatIncorrectExc","httpStatus":null,"severity":"warning","filePath":"core/agent/engine/nodes/cot/cot_runner.py","lineNumber":244,"sourceCode":"            return CotStep(thought=thought, action=action, action_input=action_input)\n\n        normalized_content = step_content.strip()\n        if (\n            allow_plain_final_answer\n            and normalized_content\n            and not any(self._marker_presence(normalized_content).values())\n        ):\n            logger.warning(\n                \"Recovering unmarked final answer after {} completed tool steps; \"\n                \"model={}, content_length={}\",\n                len(self.scratchpad.steps),\n                self.model.name,\n                len(normalized_content),\n            )\n            return CotStep(thought=normalized_content, finished_cot=True)\n\n        # 其他情况都视为无效格式\n        raise cot_exc.CotFormatIncorrectExc(\"无效的推理格式，缺少必要的标识字段\")\n\n    # Keep the streaming protocol transitions together as one state machine.\n    async def read_response(  # noqa: C901\n        self,\n        messages: LLMMessages,\n        first_loop: bool,\n        span: Span,\n        node_trace_log: NodeTraceLog,\n        allow_plain_final_answer: bool = False,\n    ) -> AsyncGenerator[AgentResponse, None]:\n\n        model_messages = messages.list()\n        with span.start(\n            \"MakingStep\",\n            attributes=llm_generation_attributes(\n                self.model,\n                input_value=model_messages,\n            ),","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/agent/engine/nodes/cot/cot_runner.py#L226-L262","documentation":"parse_cot_step classifies each LLM step: a final answer (Finished marker), a tool call (Action + Action Input), or a thought-only step. If the normalized content matches none of the recognized protocol shapes, it raises CotFormatIncorrectExc '无效的推理格式，缺少必要的标识字段' (invalid reasoning format, missing required marker fields). This is the fall-through for steps containing none of the protocol markers.","triggerScenarios":"The model returns free-form text with no Action/Action Input/Finish(finished) markers — e.g. it chats, asks a clarifying question, or emits partially malformed markers that none of PROTOCOL_MARKERS match.","commonSituations":"Model ignoring the ReAct format entirely; prompt template lost/overridden so the protocol instructions are absent; unsupported model weak at format adherence; content normalized/stripped in a way that removes markers.","solutions":["Verify the system prompt still contains the full CoT protocol template with marker examples; restore if overridden.","Switch to a model better at instruction following, or lower temperature for format stability.","Implement bounded retry: catch CotFormatIncorrectExc in the caller and reprompt with the format instructions and the error.","Log the raw step_content on failure to spot near-miss markers and extend PROTOCOL_MARKERS for common variations."],"exampleFix":"// before (model output)\n好的，我来帮您查询。\n// after (prompted format)\nThought: 用户想查询天气\nAction: amap_weather\nAction Input: {\"city\":\"合肥\"}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    step = await runner.parse_cot_step(content)\nexcept CotFormatIncorrectExc:\n    content = await reprompt_with_protocol_template(messages)\n    step = await runner.parse_cot_step(content)  # bounded retries recommended","preventionTips":["Never strip the CoT protocol section from the system prompt.","Choose models with strong instruction following for agent loops.","Log raw model output when this exception fires to refine markers/templates.","Bound retries and fall back to a direct-answer path."],"tags":["llm","cot","prompt-protocol","format"],"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"}