Skip to content

fix(claude-code): exclude synthetic turn keys from persistence waits - #312

Closed
emmang002 wants to merge 1 commit into
BytePioneer-AI:mainfrom
emmang002:codex/fix-idle-snapshot-20260917
Closed

emmang002 wants to merge 1 commit into
BytePioneer-AI:mainfrom
emmang002:codex/fix-idle-snapshot-20260917

Conversation

@emmang002

Copy link
Copy Markdown

Problem and change

A completed Claude Code autonomous Turn can leave history reads permanently returning sessionBusy. When the SDK does not expose a root User Message UUID, the transport generates an autonomous-* Turn key. The adapter currently requires that synthetic key to appear as a transcript Message UUID before readSnapshot() succeeds; it never will.

Track the actual User Message UUID separately from opaque Turn identity. The SDK transport supplies it only when observed, and history reads continue to wait for that real message and the Assistant checkpoint. Synthetic keys remain unchanged for live Turn identity but no longer enter the persistence barrier.

Validation

  • Added regression tests on unmodified upstream main 5d10dfd: both successful and failed autonomous Turns remained busy after their real checkpoint was persisted (2 failures).
  • After the fix: Claude adapter and SDK transport suites, 159 passed.
  • Guards covered: a missing real Assistant checkpoint still blocks reads; an observed autonomous User Message UUID still must persist; reading succeeds and a follow-up Turn is accepted without a synthetic transcript entry.
  • npm run build --workspace=@codexhost/adapter-claude-code: passed (TypeScript and referenced packages).
  • Focused ESLint, Prettier, and git diff --check: passed; after replacing test non-null assertions, all 3 affected adapter regressions passed again.
  • Environment: macOS arm64, Node 24.21.0. Tests use fake transports/native history, with no provider requests. Live Desktop was not restarted or modified; this is not a claim of installed-runtime acceptance.

Scope

Only the Claude adapter's internal transport and persistence bookkeeping change; no public CLI changes, message queue, timeout increase, or blanket suppression of busy checks. Related discussion: #311, but this fixes false busy during history reads, not busy-recipient report queueing or all THREAD_BUSY causes.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@BytePioneer-AI BytePioneer-AI added 功能:会话历史与恢复 会话持久化、历史读取、恢复、终态校验及安全历史替换 类型:缺陷修复 PR 修复已有行为异常;标签不表示已经复现、验收或批准合并 范围:适配器 各 Harness 的原生协议、能力、事件和会话适配实现 适配器:Claude Code 涉及 Claude Code Harness 适配或对应产品接入;不表示已经完整验收 bug Something isn't working Claude Code 历史持久化 PR 具体作用:Claude Code 历史持久化 and removed 功能:会话历史与恢复 会话持久化、历史读取、恢复、终态校验及安全历史替换 类型:缺陷修复 PR 修复已有行为异常;标签不表示已经复现、验收或批准合并 范围:适配器 各 Harness 的原生协议、能力、事件和会话适配实现 适配器:Claude Code 涉及 Claude Code Harness 适配或对应产品接入;不表示已经完整验收 labels Sep 30, 2026
@BytePioneer-AI

Copy link
Copy Markdown
Owner

感谢贡献!我们已关注到这个 PR,会尽快安排审查。
Thanks for your contribution! This PR is on our radar, and we’ll review it as soon as possible.

@BytePioneer-AI

Copy link
Copy Markdown
Owner

感谢你的贡献!想确认一下,这个 PR 当前是否已经准备好转为正式 PR(Ready for review),进入评审?

如果已经准备好,欢迎取消草稿状态;如果仍在开发、存在阻塞或希望暂缓,也欢迎简单说明当前进展,方便我们安排后续评审。谢谢!

@iruriQ

iruriQ commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

感谢排查与贡献!合成 nativeTurnKey 阻塞历史持久化等待的问题已由 #515(3c3e200af)在 main 完整解决。这边先致谢关闭本草稿!

@iruriQ iruriQ closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Claude Code 历史持久化 PR 具体作用:Claude Code 历史持久化

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants