fix(codex): keep background memory out of chats
What Changed
Codex memory consolidation runs in background threads, but T3 treated their notifications as part of the active chat. Internal messages and tool activity could therefore appear in the user's conversation.
T3 now recognizes both current and legacy memory-thread metadata and filters notifications from those threads before provider events are emitted. Tracking is removed when the internal thread closes.
Why
This keeps background memory maintenance isolated without hiding normal commentary, review or compaction work, or user-created subagents.
Fixes #4683
Validation
vp test run apps/server/src/provider/Layers/CodexSessionRuntime.test.tsvp lint apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.tsvp run --filter t3 typecheckvp fmt --check apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
Checklist
- [x] This PR is small and focused
- [x] I explained what changed and why
- [x] Screenshots are not applicable because no UI code changed
- [x] Video is not applicable because no animation or interaction changed
Built with gpt-5.6-sol using the Codex harness in T3 Code.
[!NOTE]
Filter memory consolidation thread notifications out of Codex session events
- Adds
makeMemoryConsolidationNotificationFilterinCodexSessionRuntime.tsthat tracks threads withthreadSource === 'memory_consolidation'(or legacy{ subAgent: 'memory_consolidation' }source) and returns a predicate to suppress their notifications.- Integrates the filter into
makeCodexSessionRuntimeso thatCodexSessionRuntime.eventsnever emits notifications for memory consolidation threads; suppression ends afterthread/closedis received.- Behavioral Change: clients consuming
CodexSessionRuntime.eventswill no longer see any events from memory consolidation sub-agent threads.Macroscope summarized c512b45.
[!NOTE] Medium Risk Changes Codex notification routing in the session runtime, which affects what every client sees on
events; scope is narrow and well-tested but touches collab/stop paths alongside filtering.Overview Codex memory consolidation background threads were leaking into the user chat via
CodexSessionRuntimeprovider events. This PR addsmakeMemoryConsolidationNotificationFilter, which registers threads fromthreadSource: "memory_consolidation"or legacysource.subAgent: "memory_consolidation", suppresses all subsequent notifications for those thread IDs, and clears tracking onthread/closed.
handleRawNotificationnow drops suppressed notifications before collab/parent emission, so internal deltas and warnings never reach clients. Review, compaction, and user-spawned subagents are unchanged.Tests cover filter behavior (including post-close forget) and extend the collab Stop integration scenario so memory consolidation threads still get
turn/interruptwithout surfacing as chat events.Reviewed by Cursor Bugbot for commit c512b45ab221a029790b9fb4c9cdcea515bb7a9e. Bugbot is set up for automated code reviews on this repo. Configure here.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
61ea7581-ffa1-4943-b8fe-1fac845479a6You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
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 @coderabbitai help to get the list of available commands.
Approvability
Verdict: Approved c099f5a
This PR adds a notification filter to hide background memory consolidation threads from the chat UI. The change is self-contained, well-tested, and only affects display behavior without modifying any processing logic.
You can customize Macroscope's approvability policy. Learn more.
#5219 routes registered thread_spawn collaboration agents into the Agents surface. Memory consolidation is not registered through that path, and its item/agentMessage/delta notifications can still reach the parent chat.
This PR specifically recognizes memory_consolidation, tracks that thread, and suppresses its notifications without affecting normal subagents.