Skip to content

fix(omp): tolerate late tool events from background jobs - #332

Merged
BytePioneer-AI merged 2 commits into
BytePioneer-AI:mainfrom
livisity:codex/fix-omp-late-tool-events
Sep 18, 2026
Merged

BytePioneer-AI merged 2 commits into
BytePioneer-AI:mainfrom
livisity:codex/fix-omp-late-tool-events

Conversation

@livisity

Copy link
Copy Markdown
Contributor

Summary

OMP background jobs can emit tool_execution_update and another tool_execution_end after their initial end event has removed the call from the active Tool map. The Adapter currently treats those frames as protocol faults, causing an otherwise usable Session to fail with Omp RPC returned an invalid Tool update (or Tool end).

Ignore update/end frames that cannot be associated with an active Tool, including frames arriving during a later Turn, without projecting duplicate Tool events. Keep rejecting missing, empty, or non-string call IDs during an active Turn and invalid end payloads for active Tools. Treat a missing partialResult as null, preserving other valid JSON values.

The change is confined to the OMP RPC Adapter and its tests. It adds 24 regression cases covering late/repeated frames, idle and cross-Turn delivery, unknown calls, missing fields, invalid IDs and active end payloads, and preservation of valid falsy results. No public contract, dependency, UI, or release-version changes.

Related issues

Related to #283 and #173. The previously closed, unmerged #182 was reviewed during investigation; this PR is limited to OMP Tool-frame compatibility and does not include its other changes.

Test plan

Automated checks on this branch, based on main at 6979011:

  • node node_modules/vitest/vitest.mjs run --config tests/vitest.config.js packages/adapters/omp/test packages/adapters/pi/test — 200 tests passed across 13 files (including 39 OMP RPC tests).
  • npm run typecheck — passed, including test types.
  • node node_modules/prettier/bin/prettier.cjs --check packages/adapters/omp/src/omp-rpc-session.ts packages/adapters/omp/test/omp-rpc-session.test.ts — passed.
  • node node_modules/eslint/bin/eslint.js packages/adapters/omp/src/omp-rpc-session.ts packages/adapters/omp/test/omp-rpc-session.test.ts — passed.
  • git diff --check — passed before commit.

Manual validation, performed before the final test additions and removal of unused diagnostic bookkeeping: locally built codexhost 0.9.0 with OMP 18.2.0 on WSL, accessed from Codex Desktop over SSH. A background subagent completed and delivered its result; subsequent interaction in the same Session remained usable. The user confirmed that the original failure was resolved. The exact Desktop build and OS distribution versions were not recorded for that run.

The final branch was not redeployed for another live Harness run. Windows-local OMP, macOS, ARM64, the full TypeScript suite, and Rust checks were not run locally; focused checks were selected for this Adapter-only change, with broader platform coverage left to repository CI.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4a55b1b1-262c-4672-ac1f-1531d5fe5793

📥 Commits

Reviewing files that changed from the base of the PR and between b9b598b and aaf7e96.

📒 Files selected for processing (2)
  • packages/adapters/omp/src/omp-rpc-session.ts
  • packages/adapters/omp/test/omp-rpc-session.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Check macos-14
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check windows-latest
  • GitHub Check: Check ubuntu-22.04
🧰 Additional context used
🪛 ast-grep (0.45.3)
packages/adapters/omp/src/omp-rpc-session.ts

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn, spawnSync, type ChildProcessWithoutNullStreams } from "node:child_process";
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

🔇 Additional comments (2)
packages/adapters/omp/src/omp-rpc-session.ts (1)

1433-1440: LGTM!

Also applies to: 1449-1455

packages/adapters/omp/test/omp-rpc-session.test.ts (1)

31-33: LGTM!

Also applies to: 63-66, 87-147, 213-214, 368-462, 464-535, 537-561, 563-634, 636-685, 760-760, 795-797, 810-810


📝 Summary

Summary by CodeRabbit

  • Bug 修复
    • 改进工具调用事件处理:未知、已结束或过期调用的延迟更新和完成事件将被安全忽略,减少不必要的协议错误。
    • 增加工具调用标识校验,提升异常事件处理的稳定性。
    • 完善工具结果校验,正确处理缺失的部分结果及 false、0、空字符串和 null 等有效输出。
    • 加强重复完成事件和异常工具帧的处理,提升异步任务执行可靠性。

Walkthrough

OMP 会话现在验证工具帧的调用标识,并忽略未知或已完成调用的迟到事件。测试模拟器支持注入工具帧,并覆盖异步事件、字段校验和有效空值输出。

Changes

OMP 工具帧处理

Layer / File(s) Summary
工具帧验证与状态处理
packages/adapters/omp/src/omp-rpc-session.ts
更新和完成事件先验证 toolCallId。未知或已完成调用的事件会被忽略。已跟踪调用继续校验工具名称、错误标志和结果。
模拟进程工具帧控制
packages/adapters/omp/test/omp-rpc-session.test.ts
FakeOmpProcess 支持工具帧模式、帧注入和提示回调,并模拟异步工具任务。
工具帧行为测试
packages/adapters/omp/test/omp-rpc-session.test.ts
测试覆盖延迟和重复事件、缺失字段、未知调用、过期帧、活动调用校验,以及 false、0、空字符串和 null 输出。

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: bytepioneer-ai

Merge Risk: ⚪ Minimal · up to aaf7e

The adapter change is mergeable based on the available evidence; no concrete behavior or compatibility risk remains unresolved.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:OMP 适配器现在容忍后台任务产生的迟到工具事件。标题简洁、明确,并与变更内容一致。
Description check ✅ Passed 描述与变更内容直接相关。描述说明了迟到和重复工具事件的处理、验证规则、测试范围及未执行的检查。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

@BytePioneer-AI
BytePioneer-AI merged commit 10fcf2c into BytePioneer-AI:main Sep 18, 2026
5 checks passed
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.

2 participants