Skip to content

fix(host-runtime): reconcile stale busy state from native history - #313

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

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

Conversation

@emmang002

Copy link
Copy Markdown

Problem and change

A native Codex Thread can remain THREAD_BUSY for delegation sends after its Turn has ended. #sendOfficialDelegationThread rejects immediately when #activeOfficialTurns contains the Thread, without consulting thread/read. If this Host misses a terminal notification, retries never reach the authoritative native history. Delegation reads also OR the stale cache into their reported running status.

Read native state before deciding admission. Clear a cached active Turn only when the returned history explicitly confirms that exact Turn ID completed, failed, or was interrupted/cancelled. Use the same reconciliation on delegation reads. Missing/unknown evidence stays busy; an active native Thread, running latest Turn, or newer cached Turn still blocks sending. No message queue, cancellation, polling, or live Host state reset is added.

Reproduction and validation

A hermetic Host test receives turn/started, deliberately omits turn/completed, and makes native thread/read report the same Turn completed and the Thread idle. On unmodified upstream main 5d10dfd, sending fails with THREAD_BUSY before any read. With this fix the report starts normally.

  • Focused stale-state/admission tests: 11 passed.
  • AppServerHost and HarnessDelegationCoordinator suites: 193 passed.
  • Covers completed/failed/interrupted/cancelled Turns, corrected read status, missing cached Turn in history, unknown terminal status, active Thread status, and a newer Turn starting while the read is in flight.
  • npm run build --workspace=@codexhost/host-runtime: passed.
  • Focused ESLint, Prettier, and git diff --check: passed.
  • macOS arm64 / Node 24.21.0. Fake official process and isolated temporary mapping stores only; no real Thread was sent a test message, cancelled, or restarted.

Limits and related work

This proves that a stale cache can permanently block report delivery and provides bounded reconciliation when positive evidence is available. It does not establish how a particular user's terminal notification was missed, fix thread not found, or make genuinely busy Threads accept queued reports. Native thread/read that itself remains stale/active is still rejected.

Related: #311 (separate request for async delivery to genuinely busy recipients), #312 (independent Claude history-read false-busy fix). This PR is independently based on main and requires neither change. It has not been installed into a running Desktop; live acceptance remains unverified.

@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 功能:任务委派 跨 Harness 委派、任务读取/发送/等待、协调与委派 CLI 功能:会话历史与恢复 会话持久化、历史读取、恢复、终态校验及安全历史替换 类型:缺陷修复 PR 修复已有行为异常;标签不表示已经复现、验收或批准合并 范围:宿主运行时 Host 路由、委派协调、会话生命周期及持久映射 适配器:原生Codex 官方 Codex 原生路径;不是外部 Harness 插件 bug Something isn't working Codex 会话忙碌状态 PR 具体作用:Codex 会话忙碌状态 and removed 功能:任务委派 跨 Harness 委派、任务读取/发送/等待、协调与委派 CLI 功能:会话历史与恢复 会话持久化、历史读取、恢复、终态校验及安全历史替换 类型:缺陷修复 PR 修复已有行为异常;标签不表示已经复现、验收或批准合并 范围:宿主运行时 Host 路由、委派协调、会话生命周期及持久映射 适配器:原生Codex 官方 Codex 原生路径;不是外部 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

感谢定位该问题!本草稿基于 9 月旧基线已滞留超过两个月无法直接合入,这边先致谢关闭;但我们核对确认“漏收官方 turn/completed 导致委派线程卡 THREAD_BUSY”在当前 main 上仍是真实缺陷,已单独记入缺陷清单基于最新 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 Codex 会话忙碌状态 PR 具体作用:Codex 会话忙碌状态

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants