{"record":{"id":"bc196ef34f76addd","repo":"huggingface/smolagents","slug":"no-split-token-token-provided-in-your-output","errorCode":null,"errorMessage":"No '{split_token}' token provided in your output.\nYour output:\n{model_output}\n. Be sure to include an action, prefaced with '{split_token}'!","messagePattern":"No '(.+?)' token provided in your output\\.\nYour output:\n(.+?)\n\\. Be sure to include an action, prefaced with '(.+?)'!","errorType":"exception","errorClass":"AgentParsingError","httpStatus":null,"severity":"error","filePath":"src/smolagents/agents.py","lineNumber":804,"sourceCode":"        \"\"\"\n        return list(self._step_stream(memory_step))[-1]\n\n    def extract_action(self, model_output: str, split_token: str) -> tuple[str, str]:\n        \"\"\"\n        Parse action from the LLM output\n\n        Args:\n            model_output (`str`): Output of the LLM\n            split_token (`str`): Separator for the action. Should match the example in the system prompt.\n        \"\"\"\n        try:\n            split = model_output.split(split_token)\n            rationale, action = (\n                split[-2],\n                split[-1],\n            )  # NOTE: using indexes starting from the end solves for when you have more than one split_token in the output\n        except Exception:\n            raise AgentParsingError(\n                f\"No '{split_token}' token provided in your output.\\nYour output:\\n{model_output}\\n. Be sure to include an action, prefaced with '{split_token}'!\",\n                self.logger,\n            )\n        return rationale.strip(), action.strip()\n\n    def provide_final_answer(self, task: str) -> ChatMessage:\n        \"\"\"\n        Provide the final answer to the task, based on the logs of the agent's interactions.\n\n        Args:\n            task (`str`): Task to perform.\n            images (`list[PIL.Image.Image]`, *optional*): Image(s) objects.\n\n        Returns:\n            `str`: Final answer to the task.\n        \"\"\"\n        messages = [\n            ChatMessage(","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/agents.py#L786-L822","documentation":"CodeAgent parses model output expecting an 'Code:'/'Action:' split token before the action block. extract_action splits the model output on that token; if the token is absent (or the trailing part is empty), it raises AgentParsingError telling you to preface the action with the token.","triggerScenarios":"A CodeAgent step where the LLM outputs only prose/thoughts without a final 'Code:' block; the model uses a variant like '```python' or 'Action:' instead of the expected token; empty or truncated output after the token causes the split/unpack to fail.","commonSituations":"Using a weaker or non-instruct model that ignores the ReAct format; overly chatty system prompts that bury the format instructions; token/stream truncation by max_tokens; tool-calling-formatted output in a CodeAgent.","solutions":["Retry the run; format deviations are often non-deterministic and succeed on a second attempt","Use a stronger instruction-following model or increase max_tokens to avoid truncation before the Code: block","Tighten the system/prompt template to repeat the required output format, or switch to ToolCallingAgent if the model is tuned for native tool calling","Catch AgentParsingError and feed the error message back to the model as a corrective next step (the error text already instructs it)"],"exampleFix":"# before (model output):\nI should search for the weather then report back.\n# -> AgentParsingError: No 'Code:' token provided\n\n# after (model output):\nI should search for the weather.\nCode:\npy\nweather = get_weather(\"Paris\")\nfinal_answer(f\"It's {weather}\")\n","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from smolagents import AgentParsingError\ntry:\n    agent.run(task)\nexcept AgentParsingError as e:\n    # feed the parser complaint back for one corrective retry\n    result = agent.run(str(e) + \"\\nFollow the required format exactly.\")","preventionTips":["Use instruction-tuned models with adequate max_tokens for CodeAgent","Keep the system prompt's format instructions prominent and unmodified","Consider ToolCallingAgent for models that natively emit tool calls"],"tags":["smolagents","react-parsing","codeagent","model-output-format"],"backgroundTag":"model-output-format-parse-error","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}