Skip to content

fix(opencode): retry transient provider failures and tool-call diff/input errors#15850

Open
pkellyuk wants to merge 3 commits intoanomalyco:devfrom
pkellyuk:pkellyuk/retry-local-connectivity
Open

fix(opencode): retry transient provider failures and tool-call diff/input errors#15850
pkellyuk wants to merge 3 commits intoanomalyco:devfrom
pkellyuk:pkellyuk/retry-local-connectivity

Conversation

@pkellyuk
Copy link

@pkellyuk pkellyuk commented Mar 3, 2026

Issue for this PR

Closes #15851
Closes #15906

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes two cases where sessions stopped instead of recovering:

  1. Retries transient local provider connection failures (ECONNREFUSED, ECONNRESET, nested socket causes).
  2. Retries provider tool-call stream failures like Invalid diff: now finding less tool calls! by marking them retryable.
  3. Repairs malformed tool input JSON (including JSON parsing failed: Text: ...) in experimental_repairToolCall so tool execution can continue.

Together these changes reduce hard-aborts in tool-heavy sessions and route recoverable failures into the existing retry path.

How did you verify your code works?

From packages/opencode:

  • bun test test/session/retry.test.ts test/session/llm.test.ts

Added/updated regression tests for:

  • ECONNREFUSED and related transient network errors
  • invalid tool-call diff retry classification
  • malformed/truncated tool input JSON repair

Screenshots / recordings

N/A (non-UI behavior)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@pkellyuk pkellyuk changed the title fix(opencode): retry transient local provider connection errors fix(opencode): retry transient provider failures and tool-call diff/input errors Mar 3, 2026
@pkellyuk
Copy link
Author

pkellyuk commented Mar 3, 2026

Added follow-up commit 05f1bb8 for another real-world tool-call failure:\n\n- repairs write calls where model outputs filepath/path aliases instead of filePath\n- handles tool-error while tool state is pending (prevents fallback to generic \Tool execution aborted)\n\nNew regression test added in \session/llm.test.ts\ for the \�xpected string, received undefined\ filePath case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant