fix(server): keep tool payloads out of completion queues - #12345
juliusmarminge merged 1 commit into
Conversation
Filter terminal-worker subscriptions before live buffering and historical payload decoding. Preserve matching run updates without retaining unrelated tool output while queue promotion waits on providers or thread locks.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughChangesThe orchestration event APIs now accept optional event type filters. Persistence applies the filter to replay queries. Event sinks apply it to replay and live streams through type-specific PubSubs. Startup monitoring and persistence tests use the filtered behavior. Event type filtering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Orchestrator
participant EventSinkV2
participant EventStoreV2
participant OrchestrationEventStore
participant PubSub
Orchestrator->>EventSinkV2: subscribe to run.updated
EventSinkV2->>EventStoreV2: read replay with eventType
EventStoreV2->>OrchestrationEventStore: query matching event_type
OrchestrationEventStore-->>EventSinkV2: return matching historical events
EventSinkV2->>PubSub: subscribe to run.updated channel
PubSub-->>EventSinkV2: publish matching live events
EventSinkV2-->>Orchestrator: deliver filtered stream
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The stream filtering change has no identified actionable regression and is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Thread transfer impact
This comment will update automatically after the next completed run. |
This comment has been minimized.
This comment has been minimized.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused orchestration bug fix that filters run-update events before live queue buffering and historical decoding, while preserving existing unfiltered streams and stored-event behavior. The targeted persistence and load-oriented tests cover the changed path without introducing schema, deployment, default, or static-analysis changes. You can add or adjust custom eligibility rules. Learn more. |
The terminal-run worker can wait on a provider or a thread lock while its event subscription queues every raw event. Filtering after that queue lets unrelated tool output stay in memory for the entire wait.
Filter subscriptions by event type before live publication and apply the same filter in SQL before decoding replay payloads. The completion worker subscribes to run updates, preserving their order and delivery. This is shared server behavior for every client and provider; the wire protocol is unchanged.
Based on #2829.
Before and after
A GC-checked reproduction using the application EventSink blocks the consumer on a run update, then publishes 32 unrelated events containing 16 MiB of synthetic payloads.
The new regression fails on the original implementation and passes with the fix. It verifies filtered replay, skipping unreadable unrelated payloads before decoding, and ordered live delivery through an output burst.
Validation
layerUnavailablewarning.Follow-up memory audit
Three more retention defects were reproduced and fixed in separate local commits. These follow-up fixes are not included in this PR's current head:
6b989c7bd3a7a1e84a00987a1e84a0098Each separate GC-checked reproduction retained 32 synthetic payload objects totaling 16 MiB before its fix and zero afterward. The follow-up commits passed 312 focused tests, server and transport package typechecks, and scoped lint and formatting checks. They are on the local branch
automation/provider-memory-20260917-193938and still need publication and integration.This fixes a reproduced retention defect. The available backend heap-exhaustion report does not prove it was the cause of that production crash. Integrate the change and rebuild the server or desktop bundle to apply it.
Prepared with Codex.