Skip to content

fix(provider-sync): fully isolate subagent history repair - #1869

Open
ViceEye wants to merge 5 commits into
BigPizzaV3:mainfrom
ViceEye:codex/fix-provider-sync-subagents
Open

fix(provider-sync): fully isolate subagent history repair#1869
ViceEye wants to merge 5 commits into
BigPizzaV3:mainfrom
ViceEye:codex/fix-provider-sync-subagents

Conversation

@ViceEye

@ViceEye ViceEye commented Aug 16, 2026

Copy link
Copy Markdown

Summary

This PR prevents Codex internal subagent threads from appearing as normal
sidebar conversations after running provider history repair.

It:

  • excludes subagents from rollout model_provider rewrites
  • excludes subagents from SQLite provider, has_user_event, and cwd updates
  • prevents subagents from being inserted into local_thread_catalog
  • removes subagent catalog rows that were already exposed
  • preserves explicitly user-owned threads
  • supports structured source metadata and legacy spawn-edge records
  • recovers stale provider-sync locks only when the owner process is confirmed dead
  • reports skipped repairs correctly and blocks manual repair while Codex is running

Root cause

Provider sync previously rewrote every rollout and SQLite thread to the selected
provider. Internal subagent tasks are stored in the same locations as user
threads, so changing their provider could make them eligible for normal sidebar
discovery.

has_user_event cannot distinguish these tasks because subagent rollouts may
legitimately contain user-message events.

Detection and safety

Non-root tasks are detected through:

  • rollout session_meta.source
  • SQLite source and thread_source
  • thread_spawn_edges.child_thread_id
  • existing local catalog metadata

An explicit thread_source = user marker takes precedence, so user-owned
derived threads are preserved. Ambiguous rows remain untouched.

Relationship to #1864

This PR incorporates and builds on #1864 by @Creator-hash, preserving its
original commits and authorship.

Compared with #1864, it additionally prevents internal tasks from being mutated
by provider repair in the first place. This covers rollout providers, SQLite
providers, visibility flags, working directories, and rollout-only subagent
records.

Validation

  • npm test: 56 passed
  • git diff --check: passed
  • added regression coverage for structured subagent metadata
  • added coverage for legacy spawn-edge-only records
  • added coverage for rollout-only records
  • added coverage for existing catalog cleanup
  • added coverage for explicit user-thread precedence

Rust tests and TypeScript checks were not run locally because the required Rust
toolchain and tsc are unavailable. The PR CI should run the complete checks.

sky110120 added a commit to sky110120/CodexPlusPlus that referenced this pull request Aug 17, 2026
@BigPizzaV3

BigPizzaV3 commented Aug 18, 2026

Copy link
Copy Markdown
Owner

这份改动当前不能直接合并:它与最新 main 已加入的子代理隔离逻辑,以及 #1864 的 catalog 清理/失效锁恢复大量重叠,并且 provider_sync.rs 已产生合并冲突。

其中“同时阻止 rollout、SQLite provider、has_user_event 和 cwd 被改写”的方向仍可能是有效增量。请基于最新 main rebase,并在 #1864 的增量确定后,只保留主线尚未覆盖的部分;尤其请继续保留结构化 sourcethread_source、spawn edge 和显式 thread_source = user 优先级的回归测试。这样才能单独验证它不会把普通用户会话排除在修复之外。

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.

3 participants