Skip to content

Write tool schema field ordering causes truncation failures with local models #29940

@RheagalFire

Description

@RheagalFire

Description

When local models write large files, they generate content before filePath (matching the schema declaration order). If they exhaust their token budget on content, they never
reach filePath, resulting in SchemaError(Missing key at ["filePath"]). Swapping the field order so filePath is declared first fixes this.

Related: #18108

Plugins

None

OpenCode version

Latest dev

Steps to reproduce

  1. Configure a local model (e.g. via Ollama/LiteLLM) with limited output tokens
  2. Ask it to write a large file
  3. The model generates content first, runs out of tokens, never produces filePath
  4. Results in SchemaError(Missing key at ["filePath"])

Screenshot and/or share link

N/A

Operating System

macOS

Terminal

Terminal.app

Metadata

Metadata

Assignees

Labels

No labels
No labels

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