Skip to content

Tool calls fail with JSON Parse error when description ends with a dot #24177

@NicoMaillet

Description

@NicoMaillet

Description

When the model emits a tool call (e.g., bash) where the description field ends with a dot (.), OpenCode's text extractor truncates the JSON immediately after that dot. The closing " and } are lost, causing JSON Parse error: Unterminated string or JSON Parse error: Expected '}'

Hypothesis: the pre-parser/regex that extracts JSON tool blocks from the model's raw text splits on sentence boundaries when it sees a dot inside the string value, cutting the JSON mid-object.

Workaround: just force to omit the trailing period in tool description fields. I created a skill for this and it kinda work, except when the model forget the skill.

Environment:

  • Model: Kimi 2.6 (via LiteLLM proxy, API OpenAI-compatible)
  • OpenCode version: 1.14.23 (from homebrew)
  • LiteLLM backend logs: looks clean, the malformed JSON seems generated client-side during text extraction

Plugins

No response

OpenCode version

1.14.23

Steps to reproduce

Just prompt something like "run some bash commands to test" in a fresh opencode session.

An example:

Thinking: The user wants me to run some bash commands to test the system. I should run a few basic commands to test the bash tool functionality. Let me run some simple, non-destructive commands to demonstrate the tool
⚙ invalid [tool=bash, error=Invalid input for tool bash: JSON parsing failed: Text: {"command": "echo \"Hello World\"", "description": "Test basic echo.
Error message: JSON Parse error: Unterminated string]
⚙ invalid [tool=bash, error=Invalid input for tool bash: JSON parsing failed: Text: {"command": "pwd", "description": "Test current directory command.
Error message: JSON Parse error: Unterminated string]

With the skill:

# Show current directory
$ pwd
/Users/nmaillet/Desktop/tmppp
# Display current date
$ date
ven. 24 avr. 2026 16:56:12 CEST

Screenshot and/or share link

No response

Operating System

MacOS26.4.1

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions