Repository navigation
fix(runtime): eliminate agent-send TOCTOU that rejects live agents during startup - #9166
Merged
Merged
Conversation
Contributor
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
5 tasks done
6 tasks
5 tasks done
8 of 9 tasks
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ring startup (stablyai#9166) * fix(runtime): avoid false no-agent send rejection during agent startup * fix(renderer): let guarded note sends resolve agent status races
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.
Landing recommendation
Recommended to land. The change addresses the same startup-time false negative reported in #7935, keeps the existing fail-closed write protections, has a tightly bounded slow path, and passed both focused automation and real Electron validation. PR Checks are currently green.
User problem and root cause
The user could select a live agent from Send notes to an agent and still get “not a recognized agent session” during agent startup; retrying shortly afterward worked. Instrumentation reproduced hundreds of transient
no-agentobservations during the first seconds of Claude startup.This was a TOCTOU between independent status reads:
The runtime therefore rejected a live, selected agent even though the terminal identity and permissions were otherwise valid.
Fix
no-agenthandling into the runtime send guard, which owns the final write decision.no-agentevery 150 ms, with a 1,050 ms wall-clock bound (at most 8 probes), before refusing.no-agentinstead of treating that potentially stale snapshot as final.Commits:
462e04e0d— runtime guarded-send retryae4d42b75— renderer delegates the transient case to guarded sendSafety / regression analysis
no-agentare not retried or softened.Performance
no-agent.Validation
Automated validation completed locally:
pnpm typecheckgit diff --checkReal Electron validation
Ran an isolated Electron instance from this branch with a separate user-data directory and an authenticated Claude Code terminal:
PR9166_NOTE_RECEIVED.sleep 45shell command, confirmed Orca showed Claude as Working, then sent another line-level review note to that Working target. Claude repliedPR9166_MIDTURN_RECEIVEDwhile explicitly reporting the original sleep was still running; the original command later completed and Claude returnedHOLD2_DONE.Successful guarded send from the branch diff:
Idle and mid-turn delivery markers, including completion of the original command:
Remaining risk
A naturally occurring neutral-title frame was not deterministically captured during the live Electron run. That exact timing window is covered by focused fake-timer tests for first-probe failure, eventual success, exhaustion, wall-clock bounding, and concurrent sends. Given the bounded scope and the successful idle + mid-turn end-to-end flows, remaining regression risk is low.
Fixes #7935