Skip to content

Retry failed agent starts before rejecting your message - #33045

Merged
brennanb2025 merged 292 commits into
mainfrom
brennanb2025/start-retry
Oct 25, 2026
Merged

brennanb2025 merged 292 commits into
mainfrom
brennanb2025/start-retry

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1409 $\color{#cf222e}{\Huge{\mathbf{−}}}$​99 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1310
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​610 $\color{#cf222e}{\Huge{\mathbf{−}}}$​254 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​356

A transient agent startup failure currently rejects the first message immediately. Messages waiting behind that same start can inherit its failure even though they did not request it.

Native-chat message and operation starts now silently retry eligible failures up to five attempts, with 100/200/400/800 ms between attempts. A successful retry delivers waiting messages in order. Exhaustion settles only the original requester; an operation-owned start does not reject a message that joins later. Accepted Stop prevents another attempt and suppresses a late startup-error settlement. Tracked in STA-11117 and STA-8496.

The existing start flight owns acquisition, provider opening, readiness, cancellation and final settlement. Each attempt retains its physical child identity; duplicate publications retain one copy. Intermediate failures add no error row or status churn. No saved field, wire operation, setting or minimum paired-server version is added.

Differences from the common pattern are intentional:

  • Retry stays inside the existing flight, which already owns cancellation, joiners and quit drainage.
  • A replacement requires positive exit proof from the owning host. A paired-host disconnect cannot authorize another process.
  • Typed refusals, elapsed provider-step deadlines and host faults are final immediately. All attempts share the original overall startup ceiling.
  • Retries remain process-local. Existing restart recovery holds unsent messages; no durable retry obligation is added.
  • Legacy direct attach remains one-shot under its existing operation contract.
  • The existing final error presentation remains. There is no transient retry notice or new control.
  • A failed start after provider thread creation can leave an empty provider thread, bounded to four additional threads per logical start.
  • If final journal persistence fails, ownership evidence remains and the next normal wake resumes recovery; this does not add an autonomous recovery scheduler.

Validation: CI on 5b9c8e5 passed all five Node shards, static analysis/typecheck, relay, cross-version compatibility, mobile and Windows packaging; expected headless/WSL workflows also passed. The completed shard logs explicitly record seven recorded-output cases, eight host-settlement cases and two registry cases passing. Full independent review completed in two functional rounds with no open production P0/P1. Host N4/40 contracts verify 20/200 failed starts, exact requester settlements, ordered successors, Stop precedence and retirement/isolation; registry N10/100 covers duplicate identity retention. Seven recorded-output contracts use real Claude/Codex/Pi/ACP rejection frames with command/version/exit provenance. Claude exercises its SDK callback boundary; these are representative protocol errors, not startup-auth tests or Pi/ACP app QA.

One targeted real-agent QA round passed with Claude and Codex: previous-build chats through graceful restart and two new replies each; automatic retry without resend; Stop followed by a successful new send; and five failures settling only the original requester while a queued message gets a real reply. Unmodified builds covered restart/upgrade; bounded QA-only transport instrumentation exercised actual CLI failures without changing retry or settlement policy. The incomplete initial Claude queue attempt was retained as incomplete and only that missing case was completed. The pre-turn Stop wording remains the baseline’s “Stopped manually”/“Cancellation requested”; lifecycle invariants passed, and no copy change is included. QA also passed 38 named contracts through tc-gate. Screenshots and exact evidence limits are in the review-loop status comment.

QA used production head def5845; subsequent ccf820d, c881593 and 5b9c8e5 change only tests/fixtures. Local dependencies are stale; no manual installation was performed here. All QA processes and transfer terminals stopped, five real config hashes were unchanged, and the QA slot was released.

Author: @BrennanKB5

@brennanb2025
brennanb2025 marked this pull request as ready for review October 24, 2026 05:17
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95bdaaad-bb57-4e01-be14-145bd05636cc
Commits

Reviewing files that changed from the base of the PR and between 3c8f596 and 7bf8ab1.

Files selected for processing: 3
  • mobile/src/session/mobile-native-chat-unsent-notices.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-start-settlement-host.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-delivery-notices.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The changes add structured-agent startup flights with classified retries, startup deadlines, and child-ownership tracking. Failure rows are associated with the affected queued message, and status feeds can report a session as starting before a child is ready. Tests cover repeated startup failures, settlement races, message delivery, and recovery. The Claude adapter now clears retained exit errors when session release is acknowledged. The router forwards eligible acknowledgements to the adapter.

Priority: Normal

Merge Risk: Minimal · up to 7bf8a

No specific issue from these changes remains to fix before merge; complete the planned CI and real-agent QA checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 48 functions across 51 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the change, rationale, behavior, constraints, testing, and QA results in detail. However, it does not follow the required template structure, does not provide an actual linked… Reformat the description using the repository template. Add the required section headings, provide an actual issue link or Fixes #..., state N/A with a reason for Visual Proof if no UI change exists, complete the Testing and Checklist i…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: retrying failed agent starts before rejecting the requesting message.
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.
Full details: Description check

Explanation

The description explains the change, rationale, behavior, constraints, testing, and QA results in detail. However, it does not follow the required template structure, does not provide an actual linked issue in the required format, and does not include the required Visual Proof, checklist, notes, or AI Disclosure sections.

Resolution

Reformat the description using the repository template. Add the required section headings, provide an actual issue link or Fixes #..., state N/A with a reason for Visual Proof if no UI change exists, complete the Testing and Checklist items, address Notes, and complete or explicitly apply the AI Disclosure guidance.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch brennanb2025/start-retry
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@brennanb2025

brennanb2025 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

A transient agent startup failure previously failed the first message immediately and could also fail messages waiting behind it. Native-chat message and operation starts now retry eligible failures within the original start flight, up to five attempts. A final failure belongs only to the original requester, and accepted Stop prevents any later attempt or late startup-error settlement.

Full review completed in two functional rounds. The loop fixed the accepted-Stop/final-settlement race and removed duplicate retained child identities. Later changes corrected loop-added test fixtures and added real recorded-protocol contracts; no deferred production P0/P1 remains. The architecture follows the common single-owner pattern. Intentional differences remain: positive owning-host exit proof, immediate finality for typed refusals/deadlines/host faults, one original startup ceiling, process-local retries, one-shot legacy direct attach, and the existing final presentation. Failed final journal writes retain evidence and recover on the next ordinary wake; no autonomous recovery scheduler was added.

Verification: CI on 5b9c8e5 passed all five Node shards, static analysis/typecheck, relay, cross-version compatibility, mobile and Windows packaging; expected headless/WSL workflows also passed. The completed shard logs explicitly record seven recorded-output cases, eight host-settlement cases and two registry cases passing. Host N4/40 contracts verify 20/200 failed starts plus exact requester settlements, ordered successors, Stop/no sixth attempt, retirement and isolation; registry N10/100 verifies identity retention. Recorded Claude/Codex/Pi/ACP rejection contracts preserve real command/version/exit provenance. Claude covers the SDK callback boundary rather than the SDK wire parser; these are representative protocol errors, not startup-auth runs or Pi/ACP app QA.

One targeted M4Air QA round used real Claude and Codex. Previous-build chats survived graceful restart with retained history/title/session and two new replies each. One actual startup failure retried without resend; accepted Stop prevented further attempts and the next send worked; five failures rejected only the first requester while the queued later message received a real reply. Fault scenarios used bounded, locally committed transport instrumentation with real CLI processes; retry/settlement policy was unchanged. The original incomplete Claude queue attempt was retained as incomplete, then only that missing case was completed. A literal Stop-label assertion failed because the existing UI renders “Stopped manually”/“Cancellation requested” before a provider turn exists; the same rendering is present on the baseline, and the lifecycle assertions passed. No UI copy change is included.

The QA production head was def5845d8b46005d043785e258f0efd3f2532880; later commits ccf820d4f502e3c854b66405414d14e576d76ac0, c8815937bcc3ae3311307b32ab22a8062482e5ae and 5b9c8e5318c2858b1ae692e04263e14ddd99211b change only tests/fixtures. The final head is reviewed separately. QA also passed 38 named contracts through tc-gate. Five real config hashes were unchanged, 132 recorded process identities had no survivors, all owned QA/transfer terminals were closed, and ticket 2169 was released.

For Brennan’s review

Flow Baseline / Claude PR / Codex
Previous-build conversation Baseline Claude reply Baseline Codex reply
Retained chat after graceful restart, two new replies Restored Claude chat Restored Codex folder chat
Same transient fault, baseline vs PR Baseline startup failure PR automatic Claude retry
Retry without resend Claude reply after retry Codex reply after retry
Stop wins, next send works Claude Stop then new reply Codex Stop then new reply
Five failures settle only first requester Claude later requester succeeds Codex later requester succeeds

Judgment points: retry ownership and final cancellation check, retry admission, requester-bound final row.

Since QA (10-25): main merged once (d1e2d54) to clear conflicts from the repository-wide comment cleanup and the move of the Codex app-server files into codex/app-server/. The only shipped-file change is the retry classifier's import path for the Codex request error. Two test-only commits (d01f850, 4e6039a) put a deliberate exception on the fake-timer bridge in one test for main's new real-time-wait test rule. CI is green on 4e6039a; QA evidence is from def5845.

Resolves comment-cleanup conflicts in three Claude startup tests (keeps
five-attempt assertions) and repoints the Codex request-error import
after the app-server colocation move.
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