Skip to content

refactor(plugin-sdk): expose reply-session conflict classifier - #109902

Closed
k176060444-lgtm wants to merge 1 commit into
openclaw:mainfrom
k176060444-lgtm:refactor/plugin-sdk-reply-session-conflict-classifier
Closed

k176060444-lgtm wants to merge 1 commit into
openclaw:mainfrom
k176060444-lgtm:refactor/plugin-sdk-reply-session-conflict-classifier

Conversation

@k176060444-lgtm

@k176060444-lgtm k176060444-lgtm commented Jul 17, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Plugin authors and channel extensions currently duplicate reply-session initialization conflict classification using ad hoc regex and manual error.message checks. Without a shared, stable classifier, any change to the error message breaks hard-to-find classification logic across Discord, Signal, Slack, Telegram, and WhatsApp. The Plugin SDK should expose a single predicate that extensions import and trust.

Summary

  • expose isReplySessionInitConflictError(error: unknown) through
    openclaw/plugin-sdk/error-runtime;
  • move the conflict error identity into a lightweight shared module;
  • replace duplicated classification logic in Discord, Signal, Slack,
    Telegram, and WhatsApp;
  • update the Plugin SDK API baseline, surface budget, and subpath docs.

Behavior

The shared predicate recognizes:

  • ReplySessionInitConflictError instances;
  • strictly matched legacy conflict messages;
  • raw legacy message strings;
  • wrapped conflicts in cause and error chains;
  • compatible error-like objects with an exact message.

It intentionally does not classify name-only or partial-message matches.

This normalizes wrapped-error handling and strict message matching across
channels. Retry counts, backoff, terminal behavior, and user-facing messages
are unchanged (Discord retry was already removed upstream; wrapping now
correctly routes to terminal notice).

Evidence

Unit tests

  • classifier tests: 25/25 (typed error, legacy message, raw string,
    cause-chain wrapping, error-like objects, no-throw contract, Proxy traps);
  • Plugin SDK export-contract tests: 6/6;
  • Discord: 138/138 (includes new wrapped-conflict test);
  • Signal: 7/7;
  • Slack: 13/13;
  • WhatsApp: 54/54;
  • Telegram: 115/118 (3 pre-existing Windows path-separator failures).

Static checks

  • pnpm tsgo:core — ✅;
  • pnpm check:test-types — ✅;
  • pnpm build:plugin-sdk:strict-smoke — ✅ (4/4 exports);
  • pnpm plugin-sdk:api:check — ✅;
  • pnpm plugin-sdk:surface:check — ✅ (8150 public / 4534 callable);
  • pnpm deadcode:knip — ✅;
  • pnpm deadcode:exports — ✅;
  • pnpm check:import-cycles — 0 cycles;
  • pnpm check:madge-import-cycles — 0 cycles;
  • npx oxfmt --check — 15 files correct;
  • git diff --check — clean.

Four unrelated Windows-only failures were reproduced unchanged on the
upstream/main baseline: one SQLite EBUSY cleanup failure and three Telegram
path-separator assertions.

Scope

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web scripts Repository scripts size: L triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR exposes a shared reply-session conflict classifier and replaces several channel-local matchers.

Example: A Telegram button submits /status, and dispatch throws Error("dispatch wrapper") with cause Error("reply session initialization conflicted for agent:main:telegram:9").

  • Before: The callback-local matcher misses the nested conflict.
  • After: The shared classifier recognizes it, allowing the existing callback retry to recover.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Real channel evidence supports the central behavior; SDK direction remains unresolved, and redundant tests reduce patch quality.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The contributor's real Telegram callback runs exercise the shared classifier through /status submission, with cause and error fault injection and screenshots showing final responses; this supports the demonstrated PR-era behavior, not current-main callback-local retries.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Wrapped session-conflict failures can bypass channel recovery, while plugin authors duplicate message-based classification.
Reason: Centralization has clear value, but promoting the predicate to a supported public SDK contract needs owner direction.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR retains useful shared-classifier work absent from current main and the latest stable release; it needs SDK direction and resolution of confirmed merge conflicts.

Priority: P2
Reviewed head: 8c0cbec8bdbeec0c58101d3cc0c62f9ea889afdd
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should reply-session conflict classification become a supported public error-runtime API, including typed errors, exact message formats, and cause/error wrappers?
  • Recommendation: Approve the narrow SDK contract: Retain the shared predicate, document supported inputs, and migrate only consumers that still classify these failures.
  • Why: The shared implementation has concrete consumers, but no recorded SDK-owner approval establishes its permanent public contract.

Before merge

  • Document the new public classifier contract (P3) - The new SDK export is absent from public plugin documentation, despite the body claiming a subpath-doc update. Plugin authors cannot discover its supported message and wrapper shapes or its deliberate rejection of name-only and partial matches. Add the contract to the error-runtime documentation at https://docs.openclaw.ai/plugins/sdk-subpaths. This gap was already visible at the previous reviewed head; identifying it as a finding now is a late review finding.
  • Resolve merge risk - Before merge, preserve main's actionable conflict-message suffix and support for both message formats when resolving the overlapping error-class extraction.
  • Complete next step - Resolve GitHub's confirmed merge conflicts against current main without restoring retired Telegram, Signal, or Slack retry paths or losing Discord's delivered/suppressed outcomes.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P3] Document the new public classifier contract — src/plugin-sdk/error-runtime.ts:19

Tests

  • Low-value test src/plugin-sdk/error-runtime.test.ts: Most input-shape cases duplicate the dedicated classifier suite; retain export identity and one SDK invocation smoke, removing repeated classification cases.
  • Low-value test src/auto-reply/reply/session-init-conflict-error.test.ts: The arbitrary throwing-getter case and the later Proxy get-trap case exercise the same input and assertions; consolidate them.
Agent review details

How this fits together

Reply-session initialization emits concurrency failures; core retry and channel completion owners classify them before retrying, settling ingress, or delivering a terminal notice.

flowchart TD
  A[Inbound message or callback] --> B[Reply session initialization]
  B --> C[Conflict error]
  C --> D[Shared classifier]
  D --> E[Core retry owner]
  D --> F[Channel completion owner]
  E --> B
  F --> G[Delivery or recorded settlement]
Loading

Technical review

Best possible solution:

Publish one owner-approved, documented classifier while preserving current core retry ownership and Discord delivery outcomes.

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

Source shows that top-level-only channel matchers miss nested conflicts; supplied Telegram evidence demonstrates recovery for cause and error wrappers, without a new execution during this review.

Is this the best way to solve the issue?

A shared identity and predicate is the right boundary, but integration should target current consumers rather than restore retired channel retry layers.

Full review comments:

  • [P3] Document the new public classifier contract — src/plugin-sdk/error-runtime.ts:19
    The new SDK export is absent from public plugin documentation, despite the body claiming a subpath-doc update. Plugin authors cannot discover its supported message and wrapper shapes or its deliberate rejection of name-only and partial matches. Add the contract to the error-runtime documentation at https://docs.openclaw.ai/plugins/sdk-subpaths. This gap was already visible at the previous reviewed head; identifying it as a finding now is a late review finding.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is correct
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 63bd1e92db98.

Merge-risk options

Maintainer options:

  1. Preserve the current message contract (recommended)
    Carry forward the actionable suffix and both accepted message formats during conflict resolution, with focused classifier coverage.
  2. Pause the integration
    Keep the useful shared-classifier proposal open until its conflicting owner changes can be reconciled.

Provenance checked

  • Shared session conflict identity and retry keeps the original intent (101b601: Retry transient session CAS races at the shared initializer without sleeping inside its writer lane.)
  • Channel-local classification changes intended behavior with a stated reason (Fix Slack retry for session init conflicts #99647: Recognize wrapped Slack conflicts and retain inbound work for bounded recovery; this PR explains its stricter exact matching and shared wrapper traversal.)
  • Discord terminal completion keeps the original intent (7abc666: Surface exhausted conflicts and leave failed terminal delivery retryable without duplicating inbound history.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +96, Tests +458, Generated 0, Other +2. Total +556 across 16 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 8 148 52 +96
Tests 6 462 4 +458
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 1 1 0
Other 1 4 2 +2
Total 16 615 59 +556

Review metrics

Metric Value Why it matters
Production versus test LOC Production and tooling +152/-54; tests +462/-4; generated baseline +1/-1 The positive production delta buys shared wrapper-aware classification and a public no-throw boundary, though repeated classification tests can be consolidated.
Public API additions 1 added predicate; 0 new subpaths or configuration options An existing SDK entrypoint gains a permanent callable contract requiring owner direction and documentation.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Shared conflict classification improves a bounded reliability boundary across channel consumers without establishing an urgent current regression.
  • merge-risk: 🚨 compatibility: The PR adds a supported Plugin SDK API and overlaps main's newer conflict-message contract.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The introduced PR changes Telegram callback recovery and has supplied live Telegram evidence for that behavior.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • After resolving the overlapping Discord changes, cover wrapped conflicts with quiet suppression and failed allowed terminal delivery.
  • Remove duplicate classifier cases while retaining the SDK export smoke and distinct wrapper-boundary regressions.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (28 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-15T13:21:05.068Z sha 8c0cbec :: needs real behavior proof before merge. :: [P1] Migrate the active Telegram callback owner
  • reviewed 2026-08-16T22:19:41.816Z sha 8c0cbec :: needs real behavior proof before merge. :: [P1] Migrate the active Telegram callback owner
  • reviewed 2026-08-18T12:37:45.954Z sha 8c0cbec :: needs real behavior proof before merge. :: [P1] Migrate the active Telegram callback owner
  • reviewed 2026-08-24T02:48:38.627Z sha 8c0cbec :: needs real behavior proof before merge. :: [P1] Migrate the active Telegram callback owner
  • reviewed 2026-08-27T14:32:07.479Z sha 8c0cbec :: needs real behavior proof before merge. :: [P1] Migrate the active Telegram callback owner
  • reviewed September 4, 2026, 11:59 PM ET / September 5, 2026, 03:59 UTC sha unknown :: blocked before merge. :: none
  • reviewed 2026-09-05T04:59:43.477Z sha 8c0cbec :: blocked before merge. :: none
  • reviewed 2026-09-26T22:59:09.966Z sha 8c0cbec :: blocked before merge. :: [P1] Port the classifier call to Telegram's current callback owner

Reviewed October 12, 2026, 10:47 AM ET / 14:47 UTC (Revision 29).

@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from 9720a83 to 21380d9 Compare July 17, 2026 10:50
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from 21380d9 to 44c6e75 Compare July 17, 2026 11:43
@openclaw-barnacle openclaw-barnacle Bot removed the channel: slack Channel integration: slack label Jul 17, 2026
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from 44c6e75 to fa7ecae Compare July 17, 2026 11:46
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Jul 17, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared July 17, 2026 11:59 Inactive
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from fa7ecae to a9cfd2c Compare July 17, 2026 11:59
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 17, 2026
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from a9cfd2c to 835e8d9 Compare July 17, 2026 12:14
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 17, 2026
@k176060444-lgtm

k176060444-lgtm commented Jul 18, 2026 •

Copy link
Copy Markdown
Author

Telegram wrapped reply-session conflict retry — end-to-end evidence

Tested PR #109902 at exact head:

835e8d92cc1e1def8c245985e42b47f3fa28300c

A real Telegram inline-button callback was routed through the production plugin-interaction path. The plugin handler returned submitText: "/status".

Three independent runs were performed:

Run Conflict shape Callback Production retry Attempt 2 Final client-visible response
Control R2 none 1 0 n/a 1
Wrapped conflict R1 nested under .cause 1 1 at 250 ms 1 1
Wrapped error R2 nested under .error 1 1 at 250 ms 1 1

Control run

Run ID: PR109902-CONTROL-R2

Observed:

  • callback received: 1
  • interactive handler invoked: 1
  • submitText: "/status": 1
  • production retry log: 0
  • server-side dispatch completion: 1
  • client-visible response: exactly 1
  • duplicate responses: 0
  • unauthorized responses: 0
  • transport timeouts: 0
  • model/tool calls: 0

This establishes that a normal callback does not enter the reply-session conflict retry path.

Client screenshot — Control R2

c52062d53e89014246cdfb1a71f61a1e_720

Wrapped .cause run

Run ID: PR109902-WRAPPED-CONFLICT-R1-RETRY

For the first submit attempt only, the generated runtime artifact was temporarily instrumented to throw an outer error whose nested .cause contained the exact conflict marker:

Error("dispatch wrapper")
  .cause -> Error(
    "reply session initialization conflicted for <redacted-test-session>"
  )

Observed:

  • callback received: 1
  • interactive handler invoked: 1
  • submitText: "/status": 1
  • .cause conflict injection: 1 (E2E_R1 injected wrapped conflict attempt=1)
  • production retry log: 1 (retrying in 250ms)
  • attempt 2 success: 1
  • server-side dispatch completion: 1
  • client-visible response: exactly 1
  • first failure invisible to client: true
  • duplicate responses: 0
  • unauthorized responses: 0
  • transport timeouts: 0
  • model/tool calls: 0

Client screenshot — Wrapped .cause R1

2ecaf58dff6a1c2bece57dfcf84ae1e0_720

Wrapped .error run

Run ID: PR109902-WRAPPED-ERROR-R2-CLEAN

For the first submit attempt only, the generated runtime artifact was temporarily instrumented to throw an outer error whose .error property contained the exact conflict marker:

Error("dispatch wrapper r2")
  .error -> Error(
    "reply session initialization conflicted for <redacted-test-session>"
  )

Observed:

  • callback received: 1
  • interactive handler invoked: 1
  • submitText: "/status": 1
  • .error conflict injection: 1 (E2E_R2 injected wrapped .error conflict attempt=1)
  • production retry log: 1 (retrying in 250ms)
  • attempt 2 success: 1
  • server-side dispatch completion: 1
  • client-visible response: exactly 1
  • first failure invisible to client: true
  • duplicate responses: 0
  • unauthorized responses: 0
  • transport timeouts: 0
  • model/tool calls: 0

Client screenshot — Wrapped .error R2

d29833f3b343fff32c711bc97ae05903_720

Cross-validation

The control run produced no retry, while two otherwise identical runs — one with a conflict nested only under .cause, the other under .error — each produced exactly one production retry (250 ms, matching TELEGRAM_PLUGIN_CALLBACK_SUBMIT_RETRY_DELAYS_MS[0]) and exactly one final client-visible /status response.

This confirms that isReplySessionInitConflictError correctly identifies wrapped reply-session conflicts through both .cause and .error graph paths, and that the existing Telegram callback retry mechanism handles them transparently.

Integrity

  • Generated runtime artifact was temporarily instrumented (not tracked source or PR commits)
  • Artifact restored byte-for-byte; SHA-256: bd520456e37f31a1b8a2970713035dbda6c958d810f4bb00eafbfcaea91d690c
  • Client-visible results confirmed by screenshots, not solely by outcome=completed logs
  • No tracked source files or PR commits were modified

Evidence uploaded via Hermes Agent. Review requested.

@k176060444-lgtm

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Aug 2, 2026
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from 26a4313 to a11ef41 Compare August 2, 2026 11:30
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@k176060444-lgtm
k176060444-lgtm force-pushed the refactor/plugin-sdk-reply-session-conflict-classifier branch from a11ef41 to 8c0cbec Compare August 2, 2026 11:53
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Aug 2, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Aug 29, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Sep 5, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This PR has been waiting on author changes with no commits since August 2, and it was blocked in review. If you'd still like to land a shared reply-session conflict classifier, please open a fresh PR rebased on current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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.

3 participants