[GH-ISSUE #15574] Not escaped output from model causing XML syntax error #87630

Open
opened 2026-05-10 06:10:54 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ByCzech on GitHub (Apr 14, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15574

What is the issue?

When output from model isn't escaped, contains i.e < and/or > chars, then causing Ollama XML syntax error.

Code to replicate bug:

curl -X POST http://localhost:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
  "model": "qwen3.5:9b",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": "Spusť tento kód:\n10 MODE2\n20 FORV=0TO255\n30 FORU=0TO159\n40 x=U/64-1:y=V/128-1.4\n50 z=1/SQR(x*x+y*y+1):x=x*z:y=y*z\n60 X=0:Y=.4:Z=-2\n70 P=-Y*y-Z*z:i=x*P:j=Y+y*P:k=Z+z*P:C=i*i+j*j+k*k\n80 IFC<1w=P-SQR(1-C):X=w*x:Y=Y+w*y:Z=Z+w*z:D=2*(X*x+Y*y+Z*z):x=x-D*X:y=y-D*Y:z=z-D*Z\n90 t=-(Y-1.5*SGNy)/y:u=X+x*t:v=Z+z*t\n100 S=-u*.5+v*.8:T=u*.8+v*.5\n110 GCOL0,15AND(INT(T*8)+8*INTS)\n120 PLOT69,U*8,V*4\n130 NEXT,\n140 REPEAT\n150 VDU19,U,0;0;19,U+1,4;0;19,U+2,6;0;19,U+7,7;0;19,U+8,3;0;19,U+9,1;0;5\n160 U=U+.5\n170 UNTIL0\n180 REM"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "run_microbasic",
        "description": "Spustí kód v jazyce BBC Micro Basic v emulátoru, pořídí krátký videozáznam běhu programu a vrátí výsledek.",
        "parameters": {
          "type": "object",
          "properties": {
            "source": {
              "type": "string",
              "description": "Zdrojový kód v MicroBasicu ke spuštění."
            }
          },
          "required": ["source"]
        }
      }
    }
  ]
}'

output:

{"error":"XML syntax error on line 12: element \u003cparameter\u003e closed by \u003c/function\u003e"}

Not sure, if any output from model, even not escaped should causing error on Ollama side.

Relevant log output


OS

Linux

GPU

AMD

CPU

AMD

Ollama version

0.20.5

Originally created by @ByCzech on GitHub (Apr 14, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15574 ### What is the issue? When output from model isn't escaped, contains i.e < and/or > chars, then causing Ollama XML syntax error. Code to replicate bug: ```shell curl -X POST http://localhost:11434/api/chat \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.5:9b", "stream": false, "messages": [ { "role": "user", "content": "Spusť tento kód:\n10 MODE2\n20 FORV=0TO255\n30 FORU=0TO159\n40 x=U/64-1:y=V/128-1.4\n50 z=1/SQR(x*x+y*y+1):x=x*z:y=y*z\n60 X=0:Y=.4:Z=-2\n70 P=-Y*y-Z*z:i=x*P:j=Y+y*P:k=Z+z*P:C=i*i+j*j+k*k\n80 IFC<1w=P-SQR(1-C):X=w*x:Y=Y+w*y:Z=Z+w*z:D=2*(X*x+Y*y+Z*z):x=x-D*X:y=y-D*Y:z=z-D*Z\n90 t=-(Y-1.5*SGNy)/y:u=X+x*t:v=Z+z*t\n100 S=-u*.5+v*.8:T=u*.8+v*.5\n110 GCOL0,15AND(INT(T*8)+8*INTS)\n120 PLOT69,U*8,V*4\n130 NEXT,\n140 REPEAT\n150 VDU19,U,0;0;19,U+1,4;0;19,U+2,6;0;19,U+7,7;0;19,U+8,3;0;19,U+9,1;0;5\n160 U=U+.5\n170 UNTIL0\n180 REM" } ], "tools": [ { "type": "function", "function": { "name": "run_microbasic", "description": "Spustí kód v jazyce BBC Micro Basic v emulátoru, pořídí krátký videozáznam běhu programu a vrátí výsledek.", "parameters": { "type": "object", "properties": { "source": { "type": "string", "description": "Zdrojový kód v MicroBasicu ke spuštění." } }, "required": ["source"] } } } ] }' ``` output: ```json {"error":"XML syntax error on line 12: element \u003cparameter\u003e closed by \u003c/function\u003e"} ``` Not sure, if any output from model, even not escaped should causing error on Ollama side. ### Relevant log output ```shell ``` ### OS Linux ### GPU AMD ### CPU AMD ### Ollama version 0.20.5
GiteaMirror added the bug label 2026-05-10 06:10:54 -05:00
Author
Owner

@PureBlissAK commented on GitHub (Apr 18, 2026):

🤖 Automated Triage & Analysis Report

Issue: #15574
Analyzed: 2026-04-18T18:19:30.715414

Analysis

  • Type: unknown
  • Severity: medium
  • Components: unknown

Implementation Plan

  • Effort: medium
  • Steps:

This issue has been triaged and marked for implementation.

<!-- gh-comment-id:4274305006 --> @PureBlissAK commented on GitHub (Apr 18, 2026): <!-- ollama-issue-orchestrator:v1 issue:15574 --> ## 🤖 Automated Triage & Analysis Report **Issue**: #15574 **Analyzed**: 2026-04-18T18:19:30.715414 ### Analysis - **Type**: unknown - **Severity**: medium - **Components**: unknown ### Implementation Plan - **Effort**: medium - **Steps**: *This issue has been triaged and marked for implementation.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#87630