Skip to content

retry invalid tool-call diff / malformed tool input instead of aborting #15906

Description

@pkellyuk

What happened?

During tool execution, the session can abort instead of retrying on transient provider/tool-call parsing failures.

I hit two real error shapes:

  1. Invalid diff: now finding less tool calls!
  2. Invalid input for tool write: JSON parsing failed: Text: ...

When these occur, opencode currently exits the turn instead of recovering.

Steps to reproduce

  1. Run a tool-heavy edit turn where streamed tool-call deltas are produced.
  2. Hit a provider response that emits an invalid intermediate tool-call diff.
  3. Observe abort with Tool execution aborted and Invalid diff: now finding less tool calls!.
  4. In other runs, observe abort on malformed tool input with JSON parsing failed: Text:.

Expected behavior

  • Treat transient invalid tool-call diff errors as retryable.
  • Attempt to repair malformed tool input JSON before giving up.

Additional context

I have a tested fix prepared that:

  • marks invalid tool-call diff errors as retryable
  • repairs malformed JSON tool input (including Text: payloads) and retries the tool call

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions