error parsing tool call when using GPT-OSS 20b

#173
by hona1902 - opened

I’m trying to use a GPT-OSS 20B model as the LLM inside n8n (RAG Chat Agent with tools), and I consistently get this error:

error parsing tool call: raw='{}<|call|>commentary<|message|>We have a function List_Documents1 that lists all documents. Let's call it.{}<|call|>commentary<|message|>We can get the list and then filter for document_id 4368. But the tool returns all documents; the assistant must parse the list. ...
', err=invalid character '<' after top-level value

n8n expects the model to return a single JSON object for a tool call, but instead the model outputs a string that contains:

{}<|call|>commentary to=functions.List_Documents1<|channel|>commentary <|constrain|>response<|message|>{"documents":[...]}<|call|>commentary<|message|>Now get file contents.{"file_id":"doc_4368"}...

So the first {} is valid JSON, but then the <|call|>commentary … tokens appear after it, and n8n’s JSON parser fails on the < characte
How ti fix it? Thanks in advance!

Sign up or log in to comment