[Suspected Bugs] AI Conversational Agent fail to parse text

Describe the problem/error/question

I embedded a n8n chatbot at tanyongsheng.net. It works fine at first, but when I ask the long question like: “Suggest to me where to go for a holiday trip”, it takes more than 30 seconds to load and then outputs an error code as shown below.

The error code said the AI conversational agent node failed to parse text. I suspect it’s because that node failed to handle JSON format output, so please let me know if there is any remedy

What is the error message (if any)?

Error: Failed to parse. Text: "Sure, here is a JSON markdown code snippet containing a valid JSON object in the "Option #2" format:

    "action": "Final Answer",
    "action_input": {
        "venues": [
                "name": "The Maldives",
                "description": "The Maldives is a tropical nation in the Indian Ocean composed of 26 ring-shaped atolls, which are made up of more than 1,000 coral islands. It's known for its beaches, blue lagoons and extensive reefs. The capital, Malé, has a busy fish market, restaurants and shops on the main road, Majeedhee Magu, and 17th-century Hukuru Miskiy (also known as Friday Mosque) made of carved white coral."
                "name": "Bora Bora",
                "description": "Bora Bora is a small South Pacific island northwest of Tahiti in French Polynesia. Surrounded by sand-fringed motus (islets) and a turquoise lagoon protected by a coral reef, it's known for its scuba diving. It's also home to the Bora Bora Lagoonarium, a marine-life park with pools, feeding sessions and lagoon excursions."
                "name": "Phuket",
                "description": "Phuket is one of Thailand's most popular tourist destinations, known for its beautiful beaches, lush rainforests and lively nightlife. The island is also home to a number of cultural attractions, including Buddhist temples, Chinese shrines and museums."
                "name": "Bali",
                "description": "Bali is an Indonesian island known for its forested volcanic mountains, iconic rice paddies, beaches and coral reefs. The island is home to religious sites such as cliffside Uluwatu Temple. To the south, the beachside city of Kuta has lively bars, while Seminyak, Sanur and Nusa Dua are popular resort towns. The island is also known for its yoga and meditation retreats."
                "name": "Koh Samui",
                "description": "Koh Samui is an island in the Gulf of Thailand, off the east coast of the Kra Isthmus. It's known for its beaches, rainforests and limestone cliffs. The island's capital, Chaweng, is a resort town with a busy nightlife scene. Other popular tourist destinations include Lamai Beach, Bophut Beach and Chaweng Noi Beach."
                "name": "Phu Quoc",
                "description": "Phu Quoc is an island in the Gulf of Thailand, off the coast of Vietnam. It's known for its white-sand beaches, clear waters and lush rainforests. The island's capital, Duong Dong, is a small town with a market, restaurants and shops. Other popular tourist destinations include An Thoi Town, Sao Beach and Bai Dai Beach."
```". Error: SyntaxError: Unexpected token { in JSON at position 1
    at ChatConversationalAgentOutputParser.parse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@google-ai+gen_jmndgt6w4lbkglqwwiwmr5kqie/node_modules/langchain/dist/agents/chat_convo/outputParser.cjs:62:19)
    at OutputFixingParser.parse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@google-ai+gen_jmndgt6w4lbkglqwwiwmr5kqie/node_modules/langchain/dist/output_parsers/fix.cjs:79:36)
    at AgentExecutor._call (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@google-ai+gen_jmndgt6w4lbkglqwwiwmr5kqie/node_modules/langchain/dist/agents/executor.cjs:153:26)
    at AgentExecutor.call (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@google-ai+gen_jmndgt6w4lbkglqwwiwmr5kqie/node_modules/langchain/dist/chains/base.cjs:104:28)
    at Object.conversationalAgentExecute (/usr/local/lib/node_modules/n8n/packages/@n8n/nodes-langchain/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js:57:24)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/packages/workflow/dist/Workflow.js:675:19)
    at /usr/local/lib/node_modules/n8n/packages/core/dist/WorkflowExecute.js:654:53

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: Version 1.18.0
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 20.04

Seems like it’s an issue with the LangChain: ChatConversationalAgentOutputParser Failed Parsing Due to Unexpected Tokens in JSON · Issue #2322 · langchain-ai/langchainjs · GitHub

The conversational agent node will turn out error when the text has JSON object.

But any way we could solve it in n8n?

Ok, I tested again by changing from “Google Palm ChatModel” node to “OpenAI ChatModel” node. It seems working.

I think it’s because langchain library doesn’t cope well with “Google Palm ChatModel”.

So is this issue corrected?

I have one output parser that works with a simple LLM chain but will not work with an OpenAI Assistant nor with an Agent.

not solved for me, when I used Google Palm API.

I used this prompt in the chatbot of my website: tanyongsheng.net:
“Suggest a list of places to go for a holiday trip. I want beautiful scenes.”

It returns an error as always whenever there is a JSON object in my output.

Fails for me on GPT4.5

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.