fix(opencode): wait for session completion - #217
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR replaces OpenCode's unreliable session wait endpoint with bounded polling of active-session state and message completion.
Confidence Score: 4/5The long-session polling failure should be fixed before merging because valid resumed agent runs can wait five minutes and then fail despite completing successfully. Completion polling depends on an ascending 100-message slice, while the runtime supports resumed sessions whose newly submitted prompt can fall outside that slice and remain permanently unobservable to the poll. Files Needing Attention: src/local-agent-opencode.ts
|
| Filename | Overview |
|---|---|
| src/local-agent-opencode.ts | Adds active-session completion polling, but the poll cannot find the current prompt once a resumed session exceeds the ascending 100-message window. |
| src/local-agent-opencode.test.ts | Adds coverage for the wait-endpoint readiness race, but exercises only a short, newly created session. |
Reviews (1): Last reviewed commit: "fix(opencode): wait for session completi..." | Re-trigger Greptile
| let observedActive = false; | ||
| while (true) { | ||
| const messages = await readOpencodeMessages(client, sessionId); | ||
| const activity = await active({ throwOnError: true }); | ||
| const running = isOpenCodeSessionActive(activity, sessionId); | ||
| if (running) observedActive = true; | ||
|
|
There was a problem hiding this comment.
Completion polling misses long sessions
When a resumed session already contains at least 100 messages, readOpencodeMessages repeatedly returns the oldest 100 entries, so the poll never sees the newly submitted prompt or its completion and fails the successful run with a provider timeout after five minutes.
OpenCode 1.18 accepts a prompt before its foreground session is ready, and its v2 wait endpoint can return
Session wait is not available yeteven after the model has finished. That made a successful OpenCode turn surface as a provider failure.The adapter now observes the v2 active-session lifecycle and completed projected messages, with a compatibility fallback for clients without
session.active. A regression test covers the readiness race. I verified the change withnpm run typecheck,npm test,npm run build, and a live model-identification prompt against OpenCode 1.18.19.