You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ai-opencode: RUN_FINISHED never arrives when an adapter teardown step does not settle #1638
chat() holds RUN_FINISHED until the adapter's chatStream generator returns. In @tanstack/ai-opencode 0.4.14, the finally block of OpencodeTextAdapter.chatStream awaits handle.dispose(), server.dispose(), and bridge.close() in sequence. If one of them does not settle, the text streams but the run never ends, and the HTTP response stays open.
Repro
Run chat() with opencodeText(...), withSandbox(...), and at least one tool, so that a tool bridge opens.
Wrap the sandbox provider so that process.kill() on a spawned process returns a promise that never settles (as a sandbox API call that never returns does). Or use an opencode on PATH that ignores SIGTERM and keeps a request open on the tool bridge.
Observe: TEXT_MESSAGE_END arrives, but RUN_FINISHED does not.
Proposed fix
Give each teardown step a time limit, and log a step that fails:
spawn uses detached: true, so a spawned process group gets no signal when its owner process dies, and the server continues to run with parent 1. One option: start one watchdog per owner with a stdin pipe that only the owner holds, register each spawned group with it, and kill the registered groups when the pipe closes.
While this issue was generated by claude, it's something we have experienced and verified in real world and have an pnpm patch in our repo. If you have any questions about it please let me know.
Activity
jakubriedl commentedon Oct 7, 2026
While this issue was generated by claude, it's something we have experienced and verified in real world and have an pnpm patch in our repo. If you have any questions about it please let me know.
fix(ai-opencode, ai-sandbox): end the run when a teardown step does n…
fix(ai-opencode, ai-sandbox): end the run when a teardown step does n…
feat(ai-harness): providerKeys() plugin lets each user connect their …
feat(ai-harness): Tau (#1755)
fix(ai-harness): do not run a no-user input as the session owner (#1876)