Skip to content

fix(opencode): wait for session completion - #217

Open
Waishnav wants to merge 1 commit into
codex/v11-agent-onboardingfrom
codex/v11-agent-opencode-ready
Open

fix(opencode): wait for session completion#217
Waishnav wants to merge 1 commit into
codex/v11-agent-onboardingfrom
codex/v11-agent-opencode-ready

Conversation

@Waishnav

@Waishnav Waishnav commented Aug 20, 2026

Copy link
Copy Markdown
Owner

OpenCode 1.18 accepts a prompt before its foreground session is ready, and its v2 wait endpoint can return Session wait is not available yet even 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 with npm run typecheck, npm test, npm run build, and a live model-identification prompt against OpenCode 1.18.19.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 79b1995a-893b-419e-b740-2c35110a1912

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces OpenCode's unreliable session wait endpoint with bounded polling of active-session state and message completion.

  • Polls session messages and active status until the submitted turn completes or times out.
  • Falls back to the existing wait endpoint when the active-session API is unavailable.
  • Adds a regression test covering delayed active-session readiness.

Confidence Score: 4/5

The 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

Important Files Changed

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

Comment on lines +290 to +296
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

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.

1 participant