feat(opencode): wake for background bash completions#104
Open
randomvariable wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
2 issues found across 9 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
6b2e1da to
7f6ba84
Compare
7f6ba84 to
aefe6e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #103.
This adds background-bash wake continuations for OpenCode sessions. When a background bash task completes after the agent has yielded, AFT can prompt the session with the completion summary so unattended work can continue without waiting for the user to send another message.
This pairs with OpenCode plugin transport support in anomalyco/opencode#31238. That OpenCode change ensures plugin-origin
session.promptcalls can fall back to the in-process transport when live HTTP is unauthorized.Changes
session.promptfor wake delivery, with SDK failure validation before ackassets/aft.schema.jsonConfig
New/covered
bashoptions:{ "bash": { "deferred_completion_fallback_ms": 500, "wake_retry_max_attempts": 5, "wake_debounce_step_ms": 200, "wake_debounce_cap_ms": 1000, "long_running_reminder_enabled": true, "long_running_reminder_interval_ms": 600000, "foreground_wait_window_ms": 8000, "subagent_background": false } }Tests
bun run --filter @cortexkit/aft-opencode typecheckbun test packages/opencode-plugin/src/__tests__/resolve-bash-config.test.ts packages/opencode-plugin/src/__tests__/live-server-client.test.ts packages/opencode-plugin/src/__tests__/bg-notifications.test.tsbun test packages/opencode-plugin/src/__tests__/e2e/bg-notifications.test.tsbun run --filter @cortexkit/aft-opencode buildgit diff --checkGreptile Summary
This PR implements background bash wake continuations for OpenCode sessions, allowing AFT to prompt a session with completion summaries when background tasks finish while the agent has yielded. The implementation uses
session.prompt(with SDK failure validation) as the preferred delivery path, with a tiered fallback topromptAsync, and adds an idle-independent deferred completion fallback keyed per task.ReminderClassurgency tiers (urgent_failure,timer,completion,pattern_match) so failed tasks can bypass the normal debounce delay and wake the session immediately.deferredCompletionTimer/deferredCompletionDueByTaskper-session state so completions that arrive during the same turn as their spawn fire autonomously afterdeferred_completion_fallback_msinstead of waiting for the nextsession.idleevent.probeServerReachableto reject 401/403 unless env-derived credentials make the probe succeed, and changesgetLiveServerClientto bypass the per-session cache when per-request headers (e.g.,x-aft-delivery-id) are present.Confidence Score: 5/5
Safe to merge. The core delivery logic, deferred fallback timers, urgency tiers, and hard-stop recovery are all well-covered by both unit and e2e tests.
The wake delivery chain is thoroughly tested with specific assertions on call counts, timing, and state. All three findings are style or minor behavioural nits rather than defects in the critical path.
packages/opencode-plugin/src/bg-notifications.ts — three minor findings in promoteBufferedUnknownCompletions, the deliveryIDResolved mismatch guard, and appendInTurnBgCompletions retry-state reset.
Important Files Changed
Reviews (2): Last reviewed commit: "feat(opencode): wake for background bash..." | Re-trigger Greptile