iflytek/astron-agent · warning · CotFormatIncorrectExc

无效的推理格式,缺少必要的标识字段

Error message

无效的推理格式,缺少必要的标识字段

What it means

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.

Solutions

  1. Verify the system prompt still contains the full CoT protocol template with marker examples; restore if overridden.
  2. Switch to a model better at instruction following, or lower temperature for format stability.
  3. Implement bounded retry: catch CotFormatIncorrectExc in the caller and reprompt with the format instructions and the error.
  4. Log the raw step_content on failure to spot near-miss markers and extend PROTOCOL_MARKERS for common variations.

Example fix

// before (model output)
好的,我来帮您查询。
// after (prompted format)
Thought: 用户想查询天气
Action: amap_weather
Action Input: {"city":"合肥"}
Defensive patterns

Strategy: retry

Try / catch

try:
    step = await runner.parse_cot_step(content)
except CotFormatIncorrectExc:
    content = await reprompt_with_protocol_template(messages)
    step = await runner.parse_cot_step(content)  # bounded retries recommended

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/ec2b17a26be2f144. Report an issue: GitHub.

Appendix: source

Thrown at core/agent/engine/nodes/cot/cot_runner.py:244

            return CotStep(thought=thought, action=action, action_input=action_input)

        normalized_content = step_content.strip()
        if (
            allow_plain_final_answer
            and normalized_content
            and not any(self._marker_presence(normalized_content).values())
        ):
            logger.warning(
                "Recovering unmarked final answer after {} completed tool steps; "
                "model={}, content_length={}",
                len(self.scratchpad.steps),
                self.model.name,
                len(normalized_content),
            )
            return CotStep(thought=normalized_content, finished_cot=True)

        # 其他情况都视为无效格式
        raise cot_exc.CotFormatIncorrectExc("无效的推理格式,缺少必要的标识字段")

    # Keep the streaming protocol transitions together as one state machine.
    async def read_response(  # noqa: C901
        self,
        messages: LLMMessages,
        first_loop: bool,
        span: Span,
        node_trace_log: NodeTraceLog,
        allow_plain_final_answer: bool = False,
    ) -> AsyncGenerator[AgentResponse, None]:

        model_messages = messages.list()
        with span.start(
            "MakingStep",
            attributes=llm_generation_attributes(
                self.model,
                input_value=model_messages,
            ),

View on GitHub (pinned to 5e758547a8)