Ollama μ‚¬μš© μ‹œ JSON Parse error: Unexpected EOFκ°€ λ‚˜λŠ” 문제λ₯Ό 원인-ν•΄κ²° μˆœμ„œλ‘œ λ‹€λ£Ήλ‹ˆλ‹€.

λΉ λ₯΄κ²Œ μ‹€ν–‰ (볡뢙)

{"provider":"ollama","model":"qwen3-coder","stream":false}
curl -s http://localhost:11434/api/chat -d ...
flowchart TD
A[stream=true] --> B[NDJSON]
B --> C[JSON νŒŒμ‹± μ‹€νŒ¨]
C --> D[Unexpected EOF]
D --> E[stream=false]

단계별 적용

1) 증상 확인

  • μ„€λͺ…: tool call μ‹œ Unexpected EOFκ°€ λ°œμƒν•˜λ©΄ 이 μΌ€μ΄μŠ€λ₯Ό μ˜μ‹¬ν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ μ˜ˆμ‹œ: {"provider":"ollama","model":"qwen3-coder","stream":false}

2) 원인 νŒŒμ•…

  • μ„€λͺ…: OllamaλŠ” stream=trueμ—μ„œ NDJSON을 λ°˜ν™˜ν•˜κ³ , SDKλŠ” 단일 JSON κΈ°λŒ€λ‘œ νŒŒμ‹± μ‹€νŒ¨ν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ μ˜ˆμ‹œ: curl -s http://localhost:11434/api/chat -d ...

3) μ¦‰μ‹œ ν•΄κ²°

  • μ„€λͺ…: provider 섀정에 stream:falseλ₯Ό μ μš©ν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ μ˜ˆμ‹œ: curl -s http://localhost:11434/api/chat -d ...

4) 검증

  • μ„€λͺ…: curl ν…ŒμŠ€νŠΈλ‘œ tool call 응닡을 ν™•μΈν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ μ˜ˆμ‹œ: curl -s http://localhost:11434/api/chat -d ...

5) μž₯κΈ° λŒ€μ‘

  • μ„€λͺ…: SDK 이슈 트래컀λ₯Ό κ΅¬λ…ν•˜κ³  버전 μ—…λ°μ΄νŠΈλ₯Ό ν™•μΈν•©λ‹ˆλ‹€.
  • μ‹€ν–‰ μ˜ˆμ‹œ: curl -s http://localhost:11434/api/chat -d ...

뢀둝) 원문 μ½”λ“œ μŠ€λ‹ˆνŽ« (κ²€μˆ˜μš©, μ΄ˆλ³΄μžλŠ” κ±΄λ„ˆλ›°κΈ°)

{"message":{"tool_calls":[{"function":{"name":"read","arguments":{"filePath":"README.md"}}}]}, "done":false}
{"message":{"content":""}, "done":true}
{
  "provider": "ollama",
  "model": "qwen3-coder",
  "stream": false
}
# Test with curl (should work with stream: false)
curl -s http://localhost:11434/api/chat \
  -d '{
    "model": "qwen3-coder",
    "messages": [{"role": "user", "content": "Read file README.md"}],
    "stream": false,
    "tools": [{"type": "function", "function": {"name": "read", "description": "Read a file", "parameters": {"type": "object", "properties": {"filePath": {"type": "string"}}, "required": ["filePath"]}}}]
  }'

마무리 체크

  • μœ„ β€œλΉ λ₯΄κ²Œ 싀행” λͺ…령을 μ΅œμ†Œ 1개 μ‹€ν–‰ν–ˆλ‹€.
  • μ‹€νŒ¨ μ‹œ β€œμ›λ¬Έ μ‹€ν–‰ μ½”λ“œ ν™•μž₯β€μ˜ κ΄€λ ¨ μ½”λ“œλ₯Ό μ‚¬μš©ν•΄ μž¬κ²€μ¦ν–ˆλ‹€.
  • 원본 ν•­λͺ© λŒ€μ‘° μΈλ±μŠ€μ—μ„œ λΉ μ§„ κΈ°λŠ₯이 μ—†λŠ”μ§€ ν™•μΈν–ˆλ‹€.

좜처