Skip to content

feat: add compatible turn boundary markers - #262

Merged
linrunqi08 merged 3 commits into
mainfrom
feat/turn-boundary-markers
Aug 20, 2026
Merged

feat: add compatible turn boundary markers#262
linrunqi08 merged 3 commits into
mainfrom
feat/turn-boundary-markers

Conversation

@fangxiu-wf

@fangxiu-wf fangxiu-wf commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a centralized fill-only TurnBoundaryProcessor before output dispatch
  • cover canonical root turns that have a reliable gen_ai.turn.id, while preserving producer-owned markers
  • keep Turn Boundary deduplication bounded and process-local, without participating in input checkpoints
  • strengthen the JSONL validator so complete turns missing required boundaries are rejected

Compatibility guarantees

  • existing Qoder, WorkBuddy, and Codex markers remain authoritative and unchanged
  • Codex completed/interrupted and OpenClaw llm_output terminal semantics are preserved
  • subagent records and supplemental telemetry without turn.id are skipped
  • no records are added, removed, merged, or reordered
  • event IDs, timestamps, trace context, token/message/tool data, finish reasons, OTLP span topology, and flush behavior are unchanged
  • Turn Boundary enrichment does not access StateStore or input offsets/row IDs, and does not modify Agent inputs, deployment, or Flusher implementations
  • enrichment failures are fail-open

Accepted first-stage boundaries

  • events without a reliable gen_ai.turn.id remain unchanged
  • turns without a reliable terminal signal do not receive a guessed gen_ai.turn.end
  • process-local state resets when Pilot restarts, so a turn spanning a restart may receive another gen_ai.turn.start

Validation

  • npm run typecheck
  • npm run build
  • focused Turn Boundary/InputManager/OpenClaw/validator regression: 83 passed
  • StateStore regression: 17 passed
  • OTLP trace flusher regression: 86 passed
  • full local suite: 3263 passed, 50 skipped, 0 failed
  • git diff --check

Fixes #261

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Centralized fill-only TurnBoundaryProcessor that enriches entries with reliable gen_ai.turn.start/end markers before output dispatch. Well-designed with proper fail-open semantics, producer-marker preservation, bounded state tracking, and comprehensive test coverage across unit/integration/e2e layers.

Findings

  • [Info] src/normalization/turn-boundary-processor.ts:11TERMINAL_FINISH_REASONS is duplicated in scripts/e2e/lib/e2e-scenarios.mjs:797. Consider extracting to a shared constant if the e2e validator needs to stay in sync as terminal reasons evolve.
  • [Info] src/normalization/turn-boundary-processor.tspersist() is called on every enrich() batch. For high-throughput inputs this could add I/O overhead. The current design is correct; just flagging for awareness if profiling ever surfaces this as a hotspot.

Suggestions

The implementation correctly handles the key edge cases:

  • Subagent entries are skipped (no false boundaries)
  • Producer-owned markers are never overwritten (inspect-before-fill pattern)
  • StateStore restore validates version and TTL
  • compact() caps at 4096 tracked turns with FIFO eviction

LGTM — clean, well-tested, backward-compatible change.


Automated review by github-manager-bot

…rkers

# Conflicts:
#	src/core/input-manager.ts
#	tests/unit/core/input-manager.test.ts
@linrunqi08

Copy link
Copy Markdown
Collaborator

🔍 Code Review Summary

Severity Count
Critical 0
High 0
Medium 0
Low 3

Lifecycle Verdict

Check Result
资源释放 PASS
死锁/卡死风险 PASS
状态恢复正确性 PASS
PowerShell CLM 合规 N/A

无 FAIL 项。补标器无 timer/句柄;enrich() 同步且 fail-open;跟踪故意 process-local,不写 StateStore。

Merge Gate(合入门禁)

APPROVE-READY ✅(阻断级别:Critical / High / Medium;Low 不阻断;Lifecycle 任一 FAIL 也阻断)

本轮无 open 阻断项。

总体结论

中央 fill-only TurnBoundaryProcessor 接在 InputManager last-mile enrichment 上,生产者标记保持权威,Codex/OpenClaw 终止语义与现有 OTLP 对齐,失败 fail-open,且不再参与 checkpoint。未发现阻断问题,可以合入。3 条 Low:schema 未列出 gen_ai.turn.start/end、terminal 常量与 e2e validator 重复、默认 Agent 矩阵缺 dsh

✅ Medium/High 及以上问题已全部解决,本轮评审通过(approved)。

Highlights(正向实践)

  • inspect-before-fill,含生产者 false 也不覆盖
  • 有界 process-local Map,明确不进 StateStore
  • OpenClaw llm_output / Codex turn_status 特例有单测 + 集成测试

评审报告详见: code-review/pr-262/final-report.md
Generated by LoongSuite-Pilot Code Review Agent

@linrunqi08 linrunqi08 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE-READY: no open Critical/High/Medium findings. Low items are follow-ups only.

Generated by LoongSuite-Pilot Code Review Agent

@linrunqi08
linrunqi08 merged commit cb27731 into main Aug 20, 2026
7 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.

为所有标准 AI Agent turn 兼容补充 start/end 边界

3 participants