Repository navigation
Conversation
… lead the foreground Refs #18. A fresh worker-start refused its brief at dispatch_input with agent_not_in_foreground on a single foreground read, although the agent had just reported ready: one read that caught the launcher still in front, or that could not tell, failed the start. The fork fix (a23a7be, 9e9df50, 59dbbdf) was lost in later upstream merges; this re-applies it on the current guard structure. The worker-brief guard now resamples every 250 ms for up to 10 s (LAUNCHED_AGENT_FOREGROUND_SETTLE_MS), capped by the remaining readiness budget, until the agent leads, the host's unprovable-host policy permits the write, or the window ends; the refusal names the last sample and elapsed time. A shell-return marker seen during the settle refuses before either success branch, so the Task is never pasted into a shell. Launch-prompt guards keep their single read and bare agent_not_in_foreground refusal.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This was referenced Nov 11, 2026
Owner
Author
|
Superseded by #63, merged. |
9 of 11 tasks
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.
ELI5
When Orca starts a worker, it opens a terminal, launches the agent, and then types the task in. If the agent hadn't quite taken over the terminal yet, Orca gave up on the spot and left a failed start behind. Now Orca checks a few times a second, for up to 10 seconds, and types the task as soon as the agent is in front.
What Changed
Before:
orca orchestration worker-startcould fail withstage=dispatch_input/lastError=agent_not_in_foregroundbecause the worker brief was only allowed through after a single foreground read. The new terminal was left inresidualResources, and the same terminal became ready moments later.After: the worker-brief write guard resamples the foreground every 250 ms for up to 10 s, never past the start's remaining readiness budget, and writes once the launched agent leads. If a shell prompt returns while waiting, or time runs out, it refuses and the task is never pasted into a shell. The refusal text now names the last foreground sample and the elapsed time.
Mechanism:
createLaunchedAgentWriteGuardtakes an optionalsettleDeadlineMs. OnlycreateWorkerBriefWriteGuardsets it, from a newreadinessDeadlinethatdeliverWorkerDispatchPreambleand the federation path now pass in. Launch-prompt guards keep their single read and the exact bareagent_not_in_foregroundmessage thatexternal-conversation-send.tsmatches. This restores the earlier fix (a23a7be, 9e9df50, 59dbbdf), whose code was lost in later upstream merges. It is adapted to the current guard, with theproven/shellMayHaveReturned/ unprovable-host logic unchanged.Why
The failure was a timing race and the agent became ready shortly afterwards, so waiting inside the existing readiness budget fixes it without new flags, retries or failure semantics. Re-applying the reviewed design is smaller and safer than inventing a new one.
Linked Issue
Fixes #18
Visual Proof
N/A: main-process runtime logic only; no UI change.
Testing
unknownread followed byagent(the Orchestration: dispatch input rejected after worker terminal creation #18 repro, endsready), shell-return during the wait (refuses, nothing written), an already-passed deadline, disposal during the wait, and launch prompts reading once.pnpm tc,oxlintandoxfmt --checkon the changed files, andpnpm check:code-quality:changed: all exit 0.pnpm check:flaky-test-pattern-ratchetexits 0 against the fork base.pnpm build, and any live app or PTY. This is not deployment acceptance.Review
Independent read-only review of the whole branch: clean, 0 patch findings, 8 nits and 3 deferred items. The notable nits are plain
Errorinstead of a typed class (matches the file and the exact-string match inexternal-conversation-send.ts), the overlappingreadinessTimeoutMs/readinessDeadlineparameters, and a doc note that shell-then-agent recovery usually refuses because TUI startup output looks like a shell prompt marker.settleDeadlineMsholds an absolute timestamp.Agent skill upstream boundary
Notes
federation.ts.lastErroris a free string and nothing outside tests matches the worker-start message.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (typecheck and scoped lint/tests ran locally; full test and build are left to CI)