Skip to content

Bound agent journal queue during startup - #37247

Merged
AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/fix-perf-issue
Nov 2, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/fix-perf-issue

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​204
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

Problem

If an agent produces output faster than it can be saved during startup, Orca can keep too much in memory and slow down or fail.

Solution

Limit queued startup output until Orca can pause the agent's reading. If the limit is exceeded, fail the session instead of allowing the queue to grow without bounds. Once reading control is available, continue using it to pace output.

ELI5

Orca now puts a safety limit on the pile of agent updates waiting to be saved, while still preserving final updates when a session ends.

What Changed

  • Cap the queue before reading control first binds at 1,024 operations or 32 MiB, and account for superseded updates still waiting on the journal.
  • Keep reading control bound through the final transfer so received output can drain after exit.
  • Add coverage for startup limits, queue accounting, pacing, and large final messages.

Why

Reading cannot be paused before control is bound, so the startup limit prevents unbounded memory growth. After control has bound, pacing can handle pressure without applying the startup limit to final writes.

Linked Issue

None.

Visual Proof

N/A — this changes queue handling and session cleanup without a visual or interaction change.

Testing

Added automated tests for the startup limits, queue draining, and final-message persistence. Test execution and platforms are not confirmed.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Risk

Level: Medium

An agent that exceeds the startup limit now fails its session, and incorrect queue accounting or cleanup could affect saved agent output. This affects agent sessions across platforms and remote use. A plain revert restores the previous behavior but does not recover output from a session that already failed.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Consider security, cross-platform support, remote SSH, mobile, backwards compatibility, and performance during review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@AmethystLiang
AmethystLiang force-pushed the AmethystLiang/fix-perf-issue branch from 900f2a6 to 58a3de7 Compare November 2, 2026 00:35
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: f5c64ce4-c4a5-4c69-b005-2f693fb98ee4
Commits

Reviewing files that changed from the base of the PR and between 58a3de7 and 4790afd.

Files selected for processing: 1
  • src/main/native-chat/agent-session-wire/structured-agent-session-received-output.test.ts

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

Walkthrough

The queue now enforces byte and operation limits before reading control is bound. It updates queued accounting when publications are replaced or settled. Session exit keeps reading control bound until the final timeline drains or reaches its timeout. Tests cover queue limits, startup pressure, and persistence of a large final assistant message during exit.

Merge Risk: Minimal · up to 4790a

No concrete current-head merge risk was established; the change is ready for normal validation.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main change: binding the agent journal queue during startup to control queued output.
Description check Passed The description covers the problem, solution, changes, rationale, testing scope, visual proof, risk, rollback, and checklist items. It also clearly states that test execution and platform coverage are…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 covers the problem, solution, changes, rationale, testing scope, visual proof, risk, rollback, and checklist items. It also clearly states that test execution and platform coverage are not confirmed.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 6 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • 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

Limit startup queue growth by bytes and operation count, while preserving
backpressure and allowing final Pi events to drain after exit.
@AmethystLiang
AmethystLiang force-pushed the AmethystLiang/fix-perf-issue branch from 58a3de7 to 4790afd Compare November 2, 2026 00:47
@AmethystLiang
AmethystLiang merged commit b6b07f7 into main Nov 2, 2026
54 checks passed
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