Skip to content

fix(opencode): write tool causes client to hang indefinitely when creating new files#15684

Open
Owen718 wants to merge 1 commit intoanomalyco:devfrom
Owen718:work/anomalyco-opencode-15675
Open

fix(opencode): write tool causes client to hang indefinitely when creating new files#15684
Owen718 wants to merge 1 commit intoanomalyco:devfrom
Owen718:work/anomalyco-opencode-15675

Conversation

@Owen718
Copy link
Copy Markdown

@Owen718 Owen718 commented Mar 2, 2026

Fix: write tool causes client to hang indefinitely when creating new files

The write tool was missing ctx.metadata() call that signals tool completion to the client. This caused clients (like IntelliJ with ACP) to hang indefinitely when creating new files.

  • Added ctx.metadata() call in write.ts
  • Added test to verify metadata is called

Fixes #15675

Issue for this PR

Closes #15675

Type of change

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

What does this PR do?

Problem: When using the write tool to create a new file via the ACP protocol, the client hangs indefinitely showing a "waiting" indicator. The file is successfully created on disk, but the client never receives a completion signal.

Root Cause: The write tool implementation was missing the ctx.metadata() call that signals tool completion to the client. Looking at the codebase, edit.ts and bash.ts both correctly call ctx.metadata() before returning their results, which is why those tools work properly.

Fix: Added ctx.metadata() call in write.ts immediately before returning the result. This signals to the client that the tool execution has completed successfully.

Changes:

  • packages/opencode/src/tool/write.ts: Added ctx.metadata() call with diagnostics, filepath, and exists metadata
  • packages/opencode/test/tool/write.test.ts: Added test case to verify ctx.metadata() is called during write operations

How did you verify your code works?

Ran the existing test suite for the write tool:

$ bun test test/tool/write.test.ts

✓ tool.write > new file creation > writes content to new file
✓ tool.write > new file creation > calls ctx.metadata to signal tool completion (issue #15675)
... (12 more tests)

 14 pass
 0 fail

All 14 tests pass, including the new test that specifically verifies ctx.metadata() is called.

Also verified TypeScript compilation passes.

Screenshots / recordings

N/A - This is a backend/protocol fix, no UI changes.

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2026

Hey! Your PR title Fix: write tool causes client to hang indefinitely when creating new … doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

…ating new files

The write tool was missing ctx.metadata() call that signals tool completion
to the client. This caused clients (like IntelliJ with ACP) to hang
indefinitely when creating new files.

- Added ctx.metadata() call in write.ts
- Added test to verify metadata is called

Fixes anomalyco#15675
@Owen718 Owen718 force-pushed the work/anomalyco-opencode-15675 branch from eb28492 to cfe2d58 Compare March 2, 2026 09:55
@Owen718 Owen718 changed the title Fix: write tool causes client to hang indefinitely when creating new … fix(opencode): write tool causes client to hang indefinitely when creating new files Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

write tool causes client to hang indefinitely when creating a new file

1 participant