Skip to content

fix(orchestration): deliver replyable messages to background PTYs - #8057

Open
bbingz wants to merge 3 commits into
stablyai:mainfrom
bbingz:bbingz/fix-replyable-agent-review-routing
Open

bbingz wants to merge 3 commits into
stablyai:mainfrom
bbingz:bbingz/fix-replyable-agent-review-routing

Conversation

@bbingz

@bbingz bbingz commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Orchestration mail for a background agent could remain stored until the agent checked explicitly: delivery only resolved renderer leaves, while background terminals use synthetic PTY handles. The delivery path now tries a live renderer leaf first, then a connected background PTY with an observed idle state. Queued mail is also delivered when that background PTY becomes idle.

This uses the current mailbox pointer, reservation and single-flight delivery path. It preserves Cursor's no-auto-Enter behavior and delivered-versus-read tracking. A leaf-owned handle does not take both delivery paths. SSH/folder workspace delivery shares the existing main-process PTY and mailbox contracts; no RPC or stream schema changes.

Testing and review

At 1cd52dc27fac0dadce8366053e98b425e8d71f71, independent affected-scope verification passed 2,156 tests with 11 skipped across 120 files, including the runtime harness and orchestration suites. New tests cover an already-idle background agent, a working-to-idle transition and Cursor without automatic submission.

The full non-Docker run completed with 76,622 passed, 27 failed and 391 skipped. All 27 failure identities match the established 8f78c28 baseline; there were no additional failure identities. This is not a green full run, and a fresh full 12f2c6b baseline was not run.

CLI, Node and Web TypeScript (--composite false), all changed-file lint/format, diff whitespace and native preflight/postflight passed. Independent Cursor review passed on this exact commit. Packaging and live multi-agent/SSH/Windows/Linux smoke were not run.

AI disclosure

Cursor ported and independently reviewed this change. Codex independently checked the original requirements, source, affected suites and full-run failure identities.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds routing guidance and tests that select terminal send, orchestration ask, or orchestration send/reply according to the required return path. Documents timeout, handle, and group-address constraints. Extends runtime pending-message delivery to synthetic background PTYs, including idle-transition delivery, Cursor Agent no-auto-submit behavior, and deduplication when a PTY is adopted by a renderer leaf.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary runtime change: delivering replyable orchestration messages to background PTYs.
Description check ✅ Passed The description includes all required sections, explains the change, documents testing status, and includes AI review, security, and platform notes.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e2227787-aa5e-4d19-a772-5c0fba6f46ae

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9dbba and e65630f8d0ba32c17894e76c26d66351acb404d8.

📒 Files selected for processing (8)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • skills/orca-cli/SKILL.md
  • skills/orchestration/SKILL.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from a324bc9 to b8c57ce Compare July 10, 2026 10:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: be45841f-0f7f-4035-9f2c-cee72a1c0ff0

📥 Commits

Reviewing files that changed from the base of the PR and between a324bc9139b13994ff6f06d93f01e8e993cbdeae and b8c57ce.

📒 Files selected for processing (8)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • skills/orca-cli/SKILL.md
  • skills/orchestration/SKILL.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
✅ Files skipped from review due to trivial changes (3)
  • docs/reference/2026-07-10-replyable-agent-review-routing-implementation-plan.md
  • docs/reference/2026-07-10-replyable-agent-review-routing-design.md
  • skills/orchestration/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • config/scripts/orca-cli-skill-guidance.test.mjs
  • config/scripts/orchestration-skill-guidance.test.mjs
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread skills/orca-cli/SKILL.md Resolved
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 10, 2026 16:47
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch 3 times, most recently from 2147e6b to 3e193a3 Compare July 12, 2026 10:06
@bbingz

bbingz commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main. Resolved skill/docs conflicts by keeping main agent-first + full worktree-id guidance (OMP/Pi/Grok, startupTerminal.handle) and PR replyable review routing (orchestration ask/send/reply contract).

@bbingz

bbingz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:39
@bbingz

bbingz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (34c160442f9e77d8162b4c54ecd9b39f0ba6a4f2). Conflicts resolved in: skills/orca-cli/SKILL.md (kept main's discovery stub), src/main/runtime/orca-runtime.ts (preserved background-PTY delivery + in-flight fencing with main lifecycle cleanup). Ported replyable-routing contract into skill-guides/ + regenerated bundled guides. Ready for re-review.

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch 3 times, most recently from cdd9892 to 504a83c Compare July 23, 2026 02:37
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack note

Rebased onto latest main (force-with-lease).

  • Kept background-PTY orchestration delivery path (onPtyExit keep main surfaces + clearOrchestrationDeliveryForPty)
  • Tests: orca-runtime.test.ts 861 passed after rebase

No intentional behavior change vs pre-restack tip beyond resolving main drift.

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from 504a83c to fea5063 Compare July 23, 2026 03:29
@bbingz

bbingz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Restack + review guide (community, awaiting maintainer)

Rebased onto latest main (force-with-lease). 12 commits, behind=0.

What this PR still uniquely does

Main can deliver replyable orchestration messages to renderer leaf handles when the pane is already idle. It does not push to synthetic background PTY handles (pty:…) that have no leaf.

This PR adds:

  • Resolve live background PTY for pending delivery (not only getLiveLeafForHandle)
  • Deliver on working→idle for those PTYs
  • Fence pending attempts / avoid duplicate ask retries after adoption
  • Skill-guide / docs contract for replyable routing via orchestration

Not in scope / already on main

Depends on

Suggested review focus

  • orca-runtime delivery path for synthetic handles (hot file — rebase carefully if main moves)
  • Once-only delivery after PTY adoption
  • Cursor no-auto-submit behavior for replyable asks

Tests (local)

  • orca-runtime.test.ts — 861 passed after rebase

We cannot merge; ready for upstream review when convenient.

@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from fea5063 to f5b7e87 Compare July 28, 2026 04:09
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from f5b7e87 to d91064a Compare August 6, 2026 02:21
@bbingz bbingz changed the title Deliver replyable orchestration messages to background PTYs fix(orchestration): deliver replyable messages to background PTYs Aug 6, 2026
@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from d91064a to 1cd52dc Compare September 8, 2026 22:28
@bbingz

bbingz commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current origin/main (c33a446190). Fork CI still needs maintainer Approve and run workflows. Focused tests passed locally; no origin push and no merge.

@bbingz
bbingz force-pushed the bbingz/fix-replyable-agent-review-routing branch from 1cd52dc to 5b66616 Compare September 16, 2026 03:03
bbingz and others added 3 commits September 20, 2026 19:09
Push-on-idle only resolved renderer leaves, so orchestration mail to
synthetic background-PTY handles stayed parked until a manual check.
Fall through to live connected idle PTYs on the current pointer path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Main's delivery settlement looks up a renderer leaf. Background CLI
PTYs never mint one, so the gate always refused and parked mail.
Idle was already required on the handle path.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants