Skip to content

fix(feishu): process topic sessions in parallel - #96315

Closed
LucienShui wants to merge 4 commits into
openclaw:mainfrom
LucienShui:codex/feishu-topic-parallelism-pr
Closed

LucienShui wants to merge 4 commits into
openclaw:mainfrom
LucienShui:codex/feishu-topic-parallelism-pr

Conversation

@LucienShui

Copy link
Copy Markdown

What Problem This Solves

Feishu topic group messages were effectively serialized at the WebSocket event boundary. A long-running OpenClaw turn in one topic blocked delivery and processing for messages in other topics in the same Feishu topic group.

Why This Change Was Made

This changes the Feishu monitor path so accepted WebSocket events are handed off asynchronously instead of awaiting the full agent turn before acknowledging the SDK callback. It also aligns Feishu topic session and queue keys around the native topic thread id, so messages inside one topic stay serialized while different topics use distinct sessions and queues.

User Impact

Users can mention OpenClaw in different Feishu topics in the same topic group and get parallel processing across topics. Replies remain scoped to the originating Feishu thread.

Evidence

  • Live Feishu proof in oc_52005deff2c7d4d4ce67a7871dbe5142:
    • Slow topic A: om_x100b6c9218b3dca8b274b250f4ffc70, thread omt_195fedaec30f9c8b, asked OpenClaw to run sleep 90, replied LIVE3_A_DONE_20260623_185155 at 2026-06-23 18:54.
    • Fast topic B: om_x100b6c92149e7ca4b12baba2c8ceab1, thread omt_195fed6c190f5cbe, replied LIVE3_B_DONE_20260623_185155 at 2026-06-23 18:53 while A was still running.
  • git diff --check origin/main..HEAD
  • Earlier focused local run on the same patch: node scripts/run-vitest.mjs extensions/feishu/src/monitor.message-handler.test.ts extensions/feishu/src/sequential-key.test.ts extensions/feishu/src/bot.test.ts passed 103 tests.

Known local proof gaps:

  • A rerun of the same focused Vitest command on this checkout produced no test output for over five minutes and was stopped.
  • pnpm exec oxfmt --check ... was stopped after pnpm exec started downloading optional platform packages and repeatedly hit registry download retries. Prior oxfmt on the same file set passed before PR creation.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main was stopped after 30 minutes of healthy heartbeat without a final review result.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: feishu Channel integration: feishu size: L labels Jun 24, 2026
@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 2, 2026, 3:38 AM ET / 07:38 UTC.

Summary
The branch changes Feishu group-topic session/queue keying, message receive queueing, WebSocket dispatch, docs, and tests so configured topic sessions can process in parallel.

PR surface: Source +228, Tests +548, Docs +2. Total +778 across 11 files.

Reproducibility: yes. Current main and v2026.6.11 queue normal Feishu messages by account/chat, while configured group-topic sessions are already routed by topic identity and the PR body includes live Feishu output showing topic B completing while topic A was still running after the patch.

Review metrics: 1 noteworthy metric.

  • WebSocket ACK path: 1 dispatcher wrapper added. It changes when the Feishu SDK sees handler completion relative to WebSocket acknowledgement, so maintainers need to review delivery semantics beyond CI.

Stored data model
Persistent data-model change detected: serialized state: extensions/feishu/src/bot.test.ts, serialized state: extensions/feishu/src/monitor.message-handler.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #96315
Summary: This PR is the current proof-positive canonical Feishu topic queue/session repair attempt in an overlapping cluster, but canonical does not mean merge-ready.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Fix the fallback hydration null/failure FIFO path with regression coverage.
  • Refresh the branch so the merge result can be reviewed against current main.
  • Have maintainers accept and document the WebSocket ACK timing change, or remove the wrapper.

Risk before merge

  • [P1] If a native topic starter lacks thread_id and hydration returns null or fails, a later same-topic reply with thread_id can run on a different queue key before the starter finishes, interleaving the same topic's session context.
  • [P1] The WebSocket dispatcher wrapper makes the Feishu SDK acknowledge/read the next WebSocket event before the real handler completes; maintainers need to explicitly accept that retry and delivery timing change or remove the wrapper.
  • [P1] Live GitHub reports the PR as dirty/conflicting against main, so the head needs a refresh before the final merge result can be reviewed.

Maintainer options:

  1. Repair fallback FIFO before merge (recommended)
    Keep a topic starter whose thread-id hydration fails or returns null blocking later same-chat topic events until its fallback task settles, with regression coverage.
  2. Own the early ACK behavior
    Maintainers can accept the WebSocket wrapper, but the PR should explicitly document that Feishu retry/ack timing now decouples from handler completion.
  3. Remove the dispatcher wrapper
    If queue identity plus handler fire-and-forget is enough, drop the WebSocket wrapper so the PR does not change SDK-level acknowledgement semantics.

Next step before merge

  • [P2] The fallback FIFO repair is concrete, but the dirty head and WebSocket ACK semantics require maintainer or author handling before this can be a safe automated merge path.

Security
Cleared: No concrete security or supply-chain regression was found; the diff stays within Feishu runtime, docs, and tests without dependency, workflow, secret, or package-resolution changes.

Review findings

  • [P1] Keep fallback topic starters blocking later replies — extensions/feishu/src/monitor.message-handler.ts:361-365
Review details

Best possible solution:

Land a refreshed Feishu repair that aligns queue keys with configured group-topic session identity, preserves fallback same-topic FIFO, and has maintainer-owned WebSocket ACK behavior.

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

Yes. Current main and v2026.6.11 queue normal Feishu messages by account/chat, while configured group-topic sessions are already routed by topic identity and the PR body includes live Feishu output showing topic B completing while topic A was still running after the patch.

Is this the best way to solve the issue?

No, not yet. Queue/session alignment is the right owner-boundary fix, but the best fix must preserve fallback FIFO and explicitly own or remove the early WebSocket acknowledgement wrapper.

Full review comments:

  • [P1] Keep fallback topic starters blocking later replies — extensions/feishu/src/monitor.message-handler.ts:361-365
    When a native topic starter has no thread_id, this deletes the pending chat guard before the fallback task finishes. If hydration returns no topic id or fails, a later reply with thread_id can enqueue on the topic lane and run while the starter is still running on the chat lane, breaking same-topic FIFO; keep the guard until the fallback task settles or add an equivalent fallback ordering path.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR targets a real Feishu channel workflow where one topic can block other topic messages, but the current head can still break same-topic ordering in a fallback path.
  • merge-risk: 🚨 session-state: The diff intentionally changes queue keys to follow configured topic session identity, and the fallback gap can interleave or mis-associate topic context.
  • merge-risk: 🚨 message-delivery: The diff changes Feishu WebSocket acknowledgement timing and message queueing, so mistakes can alter retry, serialization, or concurrent delivery behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies sufficient live-output proof for the main behavior, with Feishu topic ids and timestamps showing one topic completed while another was still running after the patch.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies sufficient live-output proof for the main behavior, with Feishu topic ids and timestamps showing one topic completed while another was still running after the patch.
Evidence reviewed

PR surface:

Source +228, Tests +548, Docs +2. Total +778 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 304 76 +228
Tests 3 553 5 +548
Docs 1 8 6 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 865 87 +778

What I checked:

  • Root policy read: Root AGENTS.md was read fully and applied; its review policy treats channel delivery, session state, config/defaults, and fallback behavior as merge-sensitive and requires whole-surface PR review. (AGENTS.md:1, d32c4cf3007f)
  • Scoped policy read: extensions/AGENTS.md and docs/AGENTS.md were read; the touched Feishu runtime files stay within the bundled plugin boundary and the docs edit is governed by docs rules. (extensions/AGENTS.md:1, d32c4cf3007f)
  • Current main behavior: Current main still computes normal Feishu sequential keys from account plus chat id, so configured topic-scoped sessions can still share one queue lane before this PR. (extensions/feishu/src/sequential-key.ts:16, d32c4cf3007f)
  • Latest release behavior: The latest release tag v2026.6.11 has the same account/chat-only Feishu sequential key and does not already ship the requested queue/session alignment. (extensions/feishu/src/sequential-key.ts:16, e085fa1a3ffd)
  • PR queue identity: The PR head derives Feishu group queue keys from resolveFeishuGroupSession, aligning queue identity with configured group/topic session identity. (extensions/feishu/src/sequential-key.ts:27, 22fb4e74bddb)
  • Blocking fallback defect: For topic starters without thread_id, the PR deletes the pending per-chat guard after queueing starts but before the fallback task settles, letting later same-topic replies with thread_id bypass onto a different key. (extensions/feishu/src/monitor.message-handler.ts:361, 22fb4e74bddb)

Likely related people:

  • steipete: Recent Feishu topic-group session stabilization and current-main refactors touch the session and queue surfaces this PR builds on. (role: recent topic-session contributor; confidence: high; commits: bb5e278f63bd, 27104c1afb13; files: extensions/feishu/src/bot-content.ts, extensions/feishu/src/bot.ts, extensions/feishu/src/monitor.message-handler.ts)
  • songyaolun: Commit f22fc17 introduced native thread_id preference for Feishu topic session routing, directly adjacent to the om versus omt topic identity behavior. (role: topic routing contributor; confidence: high; commits: f22fc17c78c2; files: extensions/feishu/src/bot.ts, extensions/feishu/src/bot.test.ts, extensions/feishu/src/config-schema.ts)
  • yfge: Commit 36d69d0 introduced sender/topic-scoped Feishu group session routing, which is the session identity contract reused by this PR. (role: feature introducer; confidence: high; commits: 36d69d05e212; files: extensions/feishu/src/bot.ts, extensions/feishu/src/bot.test.ts, extensions/feishu/src/config-schema.ts)
  • ngutman: Commit 4b4ec4d added Feishu /btw out-of-band lane behavior and sequential-key coverage that this PR must preserve while changing normal message lanes. (role: sequential-lane contributor; confidence: high; commits: 4b4ec4dbc298; files: extensions/feishu/src/sequential-key.ts, extensions/feishu/src/sequential-key.test.ts, extensions/feishu/src/sequential-queue.ts)
  • vincentkoc: Recent Feishu monitor error/replay work touches the same receive/dispatch path and is useful routing context for message delivery semantics. (role: recent Feishu monitor contributor; confidence: medium; commits: 6d38bd476893; files: extensions/feishu/src/monitor.message-handler.ts, extensions/feishu/src/sequential-queue.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 24, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Jun 24, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 24, 2026
@LucienShui LucienShui closed this Jul 16, 2026
@LucienShui
LucienShui deleted the codex/feishu-topic-parallelism-pr branch July 16, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu docs Improvements or additions to documentation merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant