Skip to content

fix(chat): correct native tool event correlation - #1114

Merged
shanselman merged 4 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-native-tool-correlation
Aug 7, 2026
Merged

fix(chat): correct native tool event correlation#1114
shanselman merged 4 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-native-tool-correlation

Conversation

@bkudiess

@bkudiess bkudiess commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1078, related to #894. This corrects native-tool identity, correlation, output, and error convergence without broadening into persisted-history, reconnect, renderer ownership, or storage redesign.

The final fixes preserve three abort/replay invariants:

  • A successful user abort removes only the active turn's pending replay correlations, so a late completion cannot change Interrupted to Success.
  • A failed abort retains the active correlation, allowing a late completion to repair Interrupted.
  • Aborting a later turn does not remove prior-turn legacy replay correlations.

Scope

The PR remains limited to:

  • src/OpenClaw.Chat/ChatModels.cs
  • src/OpenClaw.Chat/ChatTimelineReducer.cs
  • src/OpenClaw.Tray.WinUI/Chat/NativeToolProjector.cs
  • src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs
  • tests/OpenClaw.Tray.Tests/ChatTimelineReducerTests.cs
  • tests/OpenClaw.Tray.Tests/NativeToolProjectorTests.cs
  • tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs

The branch was updated from current main without rewriting history. Remote head f58fd68154c2d2c972dc4d55645b8d1ff2dad85c has tree 5f1637a722da0127f572eca2ebab2b087dc01bf4, exactly matching validated integration 31319859.

Validation

Check Result
./build.ps1 Passed, including documentation validation
Focused abort/replay tests 7/7 passed
Shared tests 3,412 passed, 32 skipped, 0 failed
Tray tests 2,204/2,204 passed
Reactor tool activity proof 1/1 passed
Native identity UIA proof 1/1 passed
Targeted CI timeout reproduction 1/1 passed locally
Exact-head GitHub test rerun Passed
Exact-head win-x64 build Passed
Exact-head win-arm64 build Passed
Exact-head E2E shards 3/3 passed
Exact-head repo hygiene and security gates Passed

The local Axe category repeatedly passed 19/20 cases but reported host-sensitive ClickablePointOnScreen geometry failures on different Chat page controls. The exact-head GitHub test rerun, which includes the clean-run Axe gate, passed. The first CI attempt had one unrelated SystemRun_Where_ReturnsExpectedOutput timeout (-1); that test passed locally and the full exact-head rerun passed.

Real behavior proof

This is source-derived synthetic parser/provider/reducer and production-renderer UIA proof, not a real Gateway capture. Exact validated tree output:

UIA expanded="Activity: Ran 2 commands, used Apply Patch. 3 tools. Collapsed."
UIA expanded="Tool call Bash. Done."
UIA expanded="Tool call Apply Patch. Done."
UIA expanded="Tool call Tool. Done."
UIA input="command: powershell -NoProfile -Command Get-ChildItem .\src"
UIA input="file_path: src\OpenClaw.Chat\ChatTimelineReducer.cs"
UIA input="command: [redacted]"
forbidden proof-run-=absent
forbidden super-secret-value=absent
result=pass

A current-head screenshot was not retained because capture on this host was blank or near-uniform. Semantic UIA assertions and the exact-head CI UI suite passed.

Real Gateway proof: Not verified. This validation intentionally used source-derived Core envelopes and the production rendering path.

Review

Final rubber-duck review verified all three abort/replay invariants and reported no blocking findings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@bkudiess

bkudiess commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@bkudiess

bkudiess commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@bkudiess
bkudiess marked this pull request as ready for review August 6, 2026 22:39
@bkudiess
bkudiess marked this pull request as draft August 6, 2026 22:41
@bkudiess
bkudiess marked this pull request as ready for review August 6, 2026 23:05
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Aug 6, 2026
@clawsweeper

clawsweeper Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codex review: found issues before merge. Reviewed August 7, 2026, 2:38 PM ET / 18:38 UTC.

ClawSweeper review

What this changes

The PR changes native chat correlation so tool, command, patch, output, and error events update one safely projected activity row.

Merge readiness

Blocked by patch quality or review findings - 5 items remain

Keep open. The branch still drops the current legacy parent-item correlation path, and its supplied proof is synthetic and predates the current PR head.

Priority: P2
Reviewed head: f58fd68154c2d2c972dc4d55645b8d1ff2dad85c

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 4 items Legacy route is removed: The PR extractor accepts toolCallId or itemId only, removing the existing parentItemId and related parent aliases.
Current-main regression coverage: Current main explicitly tests a tool parent with itemId tool-1 and a command child with parentItemId tool-1 plus itemId command-1; the PR replaces this legacy fixture family.
Prior blocker remains: The previous review raised this same P1; the extractor body at the earlier reviewed head has the same toolCallId/itemId-only logic.
Findings 1 actionable finding [P1] Preserve legacy parent-item correlation
Security None None.

How this fits together

Gateway agent events enter the tray chat provider, which extracts safe tool data and sends normalized events to the timeline reducer. The reducer correlates them into native chat activity rows.

flowchart LR
A[Gateway agent events] --> B[Chat event provider]
B --> C[Safe tool projection]
C --> D[Timeline correlation]
D --> E[Native chat activity rows]
Loading

Before merge

  • Preserve legacy parent-item correlation (P1) - Current main supports children with parentItemId: "tool-1" and itemId: "command-1". This extractor now returns command-1 when toolCallId is absent, so the provider buffers the child presentation and output instead of updating the existing parent row. Retain the legacy parent fallback after toolCallId and restore its regression test.
  • Resolve merge risk (P1) - Merging as written breaks existing Gateway child envelopes that use parentItemId without toolCallId: command details and output are buffered under the child ID instead of updating the parent activity row.
  • Resolve merge risk (P1) - The submitted screenshot is synthetic, from an earlier head, and does not prove the live Gateway event path at the current head.
  • Complete next step (P2) - The concrete compatibility repair is clear, but the remaining current-head real Gateway proof must come from the contributor's setup before merge.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P1] Preserve legacy parent-item correlation — src/OpenClaw.Tray.WinUI/Chat/NativeToolProjector.cs:119-138
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test delta production +345/-96, tests +656/-102 The seven-file change substantially replaces existing correlation fixtures, so legacy compatibility coverage is material.
Proof freshness 3 commits after validated head The PR body validates and proves 76a9bac, while the current head is f58fd68.

Merge-risk options

Maintainer options:

  1. Restore legacy correlation (recommended)
    Keep opaque nonempty toolCallId first, then fall back to the supported parent-item aliases before itemId normalization, with a parent-child-output regression test.
  2. Pause pending compatibility proof
    Do not merge while existing parentItemId-only Gateway frames lose their parent-row updates and current-head live Gateway proof is absent.

Technical review

Best possible solution:

Preserve toolCallId precedence, retain the legacy parent aliases before itemId fallback, restore regression coverage for the supported parent-child shape, then provide a redacted current-head live Gateway trace or UI proof.

Do we have a high-confidence way to reproduce the issue?

Yes, from source. Replay the current-main parent tool and parentItemId-only command-child fixture: the PR resolves the child as command-1 rather than tool-1, so its presentation and output cannot update the existing parent row.

Is this the best way to solve the issue?

No. The new normalized route is useful, but removing the legacy parent fallback is not safe while current main documents and tests that envelope shape.

Full review comments:

  • [P1] Preserve legacy parent-item correlation — src/OpenClaw.Tray.WinUI/Chat/NativeToolProjector.cs:119-138
    Current main supports children with parentItemId: "tool-1" and itemId: "command-1". This extractor now returns command-1 when toolCallId is absent, so the provider buffers the child presentation and output instead of updating the existing parent row. Retain the legacy parent fallback after toolCallId and restore its regression test.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2439d4371096.

Labels

Label justifications:

  • P2: The defect affects a bounded native-chat tool activity workflow rather than core runtime availability.
  • merge-risk: 🚨 compatibility: The PR removes a currently supported parentItemId correlation path used by existing Gateway envelopes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

Likely related people:

  • bkudiess: Merged native-tool identity work established this projection and correlation surface. (role: introduced native tool identity behavior; confidence: high; commits: ad472243bcb8; files: src/OpenClaw.Tray.WinUI/Chat/NativeToolProjector.cs, src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs)
  • calebeden: Merged compact tool-activity work most recently changed the reducer and provider path surrounding this correlation behavior. (role: recent adjacent chat activity contributor; confidence: high; commits: aac07abb1fbd; files: src/OpenClaw.Chat/ChatTimelineReducer.cs, src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-06T23:35:55.067Z sha 76a9bac :: needs changes before merge. :: [P1] Retain legacy parent-item correlation for command children
  • reviewed 2026-08-07T16:01:31.744Z sha 76a9bac :: needs changes before merge. :: [P1] Retain legacy parent-item correlation for command children

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 7, 2026
shanselman and others added 3 commits August 7, 2026 11:14
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@shanselman
shanselman merged commit a1d933a into openclaw:main Aug 7, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants