Solution skill
ValueError: Could not parse LLM output:
Complete solution
Shows how to fix valueError: Could not parse LLM output:. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Fix: use an instruction-tuned model that follows formatting instructions (OpenAI models worked in this thread). The hacks that patch site-packages output parsing are fragile; the model choice is the real fix.
Steps
- 'Could not parse LLM output' from a LangChain agent almost always means the model isn't following the ReAct format: models like google/flan-t5-xl or Bloom don't reliably produce the Thought / Action / Action Input structure the parser expects. Fix: use an instruction-tuned model that follows formatting instructions (OpenAI models worked in this thread). The hacks that patch site-packages output parsing are fragile; the model choice is the real fix.
When to use
You are seeing this: https://github.com/langchain-ai/langchain/issues/1358: Issue langchain-ai/langchain#1358 (closed, 82 comments): agent\chain = initialize\agent( tools=tools, llm= HuggingFaceHub(repo\_id="google/flan-t5-xl"), agent="conversational-react-description",... Use this skill when you run into "ValueError: Could not parse LLM output:".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/langchain-ai/langchain/issues/1358:
Evidence
Issue gh:langchain-ai/langchain#1358: the reporter asked: Issue langchain-ai/langchain#1358 (closed, 82 comments): `agentchain = initializeagent( tools=tools, llm= HuggingFaceHub(repo_id="google/flan-t5-xl"), agent="conversational-react-description", memory=memory, verbose=False)
agent_chain.run("Hi")`
throws error. This happens with Bloom as well. Agent only with OpenAI is only working well.
(self, inputs, returnonlyoutputs) 140 except (KeyboardInterrupt, Exception) as e: 141 self.callbackmanager.onchainerror(e, verbose=self.verbose) --> 142 raise e 143 self.callbackmanager.onchain_end(outputs, verbose=self.verbose) ... ---> 83 raise... The verified answer was: 'Could not parse LLM output' from a LangChain agent almost always means the model isn't following the ReAct format: models like google/flan-t5-xl or Bloom don't reliably produce the Thought / Action / Action Input structure the parser expects. Fix: use an instruction-tuned model that follows formatting instructions (OpenAI models worked in this thread). The hacks that patch site-packages output parsing are fragile; the model choice is the real fix. Evidence thread: https://github.com/langchain-ai/langchain/issues/1358
By @issueatlas · Version 2 · 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_bamOXt_l4np7VWXKcGgjsA" 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">ValueError: Could not parse LLM output: <span>— Vectle</span></a>