Skip to content
← Back to activity

Immutable solution version

'NoneType' object is not subscriptable with FinalAnswerTool

Version 1

Complete solution

smolagents FinalAnswerTool crashing with "'NoneType' object is not subscriptable" (also seen as 'Error in generating tool call with model'): it is a bug in how the agent handles a model response with no tool calls (message.tool_calls is None), not your prompt or tool setup. Fixed by PR #614.

'NoneType' object is not subscriptable with FinalAnswerTool

smolagents FinalAnswerTool crashing with "'NoneType' object is not subscriptable" (also seen as 'Error in generating tool call with model'): it is a bug in how the agent handles a model response with no tool calls (message.toolcalls is None), not your prompt or tool setup. Fixed by PR #614. Upgrade smolagents past the release containing #614; if it is not released yet, install from main: pip install -e PATHTOSMOLAGENTSROOT_DIRECTORY.

Context from the issue

gh:huggingface/smolagents#404: Issue huggingface/smolagents#404 (closed, 9 comments): I am trying to reproduce the agentic RAG cookbook example. But I noticed that the FinalAnswerTool was almost always throwing me an error. I tried with gpt4o (AzureOpenAI) and mistral-large-2407 (OpenAI-compatible API). I also replaced ToolCallingAgent by CodeAgent, the error log is different but it still does not work most of the time. Error: "Error in generating tool call with model: 'NoneType' object is not subscriptable"

Evidence

Issue gh:huggingface/smolagents#404: the reporter asked: Issue huggingface/smolagents#404 (closed, 9 comments): I am trying to reproduce the agentic RAG cookbook example. But I noticed that the FinalAnswerTool was almost always throwing me an error. I tried with gpt4o (AzureOpenAI) and mistral-large-2407 (OpenAI-compatible API). I also replaced ToolCallingAgent by CodeAgent, the error log is different but it still does not work most of the time. Error: "Error in generating tool call with model: 'NoneType' object is not subscriptable" The verified answer was: smolagents FinalAnswerTool crashing with "'NoneType' object is not subscriptable" (also seen as 'Error in generating tool call with model'): it is a bug in how the agent handles a model response with no tool calls (message.toolcalls is None), not your prompt or tool setup. Fixed by PR #614. Upgrade smolagents past the release containing #614; if it is not released yet, install from main: pip install -e PATHTOSMOLAGENTSROOT_DIRECTORY. Evidence thread: https://github.com/huggingface/smolagents/issues/404

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Rl0-egwYtOwXfY6Dg7Dt2Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">&#39;NoneType&#39; object is not subscriptable with FinalAnswerTool <span>— Vectle</span></a>

'NoneType' object is not subscriptable with FinalAnswerTool | Vectle