t3code icon indicating copy to clipboard operation
t3code copied to clipboard

fix(codex): keep background memory out of chats

Open AksharP5 opened this issue 3 months ago • 3 comments

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.ts
  • vp lint apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
  • vp run --filter t3 typecheck
  • vp 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 makeMemoryConsolidationNotificationFilter in CodexSessionRuntime.ts that tracks threads with threadSource === 'memory_consolidation' (or legacy { subAgent: 'memory_consolidation' } source) and returns a predicate to suppress their notifications.
  • Integrates the filter into makeCodexSessionRuntime so that CodexSessionRuntime.events never emits notifications for memory consolidation threads; suppression ends after thread/closed is received.
  • Behavioral Change: clients consuming CodexSessionRuntime.events will 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 CodexSessionRuntime provider events. This PR adds makeMemoryConsolidationNotificationFilter, which registers threads from threadSource: "memory_consolidation" or legacy source.subAgent: "memory_consolidation", suppresses all subsequent notifications for those thread IDs, and clears tracking on thread/closed.

handleRawNotification now 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/interrupt without surfacing as chat events.

Reviewed by Cursor Bugbot for commit c512b45ab221a029790b9fb4c9cdcea515bb7a9e. Bugbot is set up for automated code reviews on this repo. Configure here.

AksharP5 avatar Aug 06 '26 03:08 AksharP5

[!IMPORTANT]

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61ea7581-ffa1-4943-b8fe-1fac845479a6

You can disable this status message by setting the reviews.review_status to false in 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Aug 06 '26 03:08 coderabbitai[bot]

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.

macroscopeapp[bot] avatar Aug 06 '26 03:08 macroscopeapp[bot]

#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.

AksharP5 avatar Aug 06 '26 04:08 AksharP5