Skip to content

fix(msteams): broadcast entries split group chat sessions and ignore the documented key form - #190799

Open
jerome-queck wants to merge 5 commits into
openclaw:mainfrom
jerome-queck:fix/msteams-broadcast-route-peer
Open

jerome-queck wants to merge 5 commits into
openclaw:mainfrom
jerome-queck:fix/msteams-broadcast-route-peer

Conversation

@jerome-queck

@jerome-queck jerome-queck commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #190740

What Problem This Solves

Fixes: in Microsoft Teams group chats and channels, adding a documented broadcast["msteams:<conversationId>"] entry does nothing, while the undocumented msteams:conversation:<id> key fans out into a different session (…:group:conversation:<id>), so adding/removing broadcast splits the routed agent's history.

User Impact

User impact: Teams broadcast entries now use the documented "<channel>:<peerId>" form with the bare conversation id, and the routed agent keeps the same session with or without broadcast.

Existing prefixed keys / stored histories (no migration, nothing deleted): configs that used the undocumented msteams:conversation:<id> key stop matching and fall back to the ordinary single-agent route; rename the key to msteams:<id>. Transcripts already written under agent:<id>:msteams:group:conversation:<id> are left untouched on disk and are not merged or deleted; after this change new turns continue in the ordinary agent:<id>:msteams:group:<id> session (the same one used before broadcast was added). Operators who want the in-between history can read or reuse those old sessions manually.

Why This Change Was Made

Teams built its inbound context without conversation.routePeer, so core group-thread dispatch fell back to the prefixed OriginatingTo (conversation:<id>) — or, for channels, the Graph team/channel native id. Teams now publishes the same peer it passes to resolveAgentRoute (bare conversation id; sender id for DMs), matching Slack and Discord. Plugin-local only; no core changes. Docs gain a Teams example of the key form.

Evidence

New extensions/msteams/src/monitor-handler/message-handler.broadcast.test.ts runs real Teams inbound preparation (createMSTeamsMessageHandler + real buildChannelInboundEventContext + real resolveAgentRoute) into the real core dispatchInboundMessage (including group-thread fan-out); only the agent reply is stubbed.

Red on main (c268e6e), fix stashed:

 × keeps the routed agent's session when a documented broadcast entry is added or removed
   AssertionError: expected [ 'main' ] to deeply equal [ 'helper', 'main' ]
 × does not match the legacy conversation-prefixed broadcast key
   AssertionError: expected [ … ] to have a length of 1 but got 2

Green with fix: both pass; whole extensions/msteams/src/monitor-handler suite 9 files / 94 tests pass.

Before/after session keys for chat 19:[email protected] (same harness, probe not committed):

BEFORE no broadcast                  => main: agent:main:msteams:group:19:[email protected]
BEFORE msteams:<chat>                => main only (entry ignored)
BEFORE msteams:conversation:<chat>   => main: agent:main:msteams:group:conversation:19:[email protected]  ← split history
                                        helper: agent:helper:msteams:group:conversation:19:[email protected]
AFTER  no broadcast                  => main: agent:main:msteams:group:19:[email protected]
AFTER  msteams:<chat>                => main: agent:main:msteams:group:19:[email protected]  ← same session
                                        helper: agent:helper:msteams:group:19:[email protected]
AFTER  msteams:conversation:<chat>   => main only (legacy key no longer matches)

Local pnpm check:changed: format, typecheck extensions + extension tests, lint, plugin boundaries, mock-export ratchet, import cycles all ok. Live Gateway and upgrade runs: see Real behaviour proof below.

Update (d7aa32f): Doctor migration for legacy keys

  • extensions/msteams/config-doctor-api.ts now owns a legacy rule + normalizeCompatibilityConfig step that moves broadcast."msteams:conversation:<id>" → broadcast."msteams:<id>" on openclaw doctor --fix. Existing canonical entries are never overwritten (a warning is emitted and both keys are left as-is).
  • The previous legacy-rejection test was replaced by a migration regression: migrate a legacy config, then run the real Teams inbound → core dispatch path and assert both participants fan out with stable agent:<id>:msteams:group:<chat> sessions; plus a no-overwrite test.
  • Stored data: session keys are unchanged by this PR (agent:main:msteams:group:<chat> before and after), so existing transcripts keep resolving; only the config key is rewritten.

Update (follow-up): collisions + channel keys

  • Collision: when both msteams:conversation:<id> and msteams:<id> exist, Doctor now keeps the canonical value and removes the superseded key (warning if values differed), so the legacy rule no longer matches and repair completes; the second run is a no-op (tested for identical and differing values).
  • Channel keys: routePeer is now published only for group chats. Teams channels keep their existing broadcast identity (msteams:<teamAadGroupId>/<graphChannelId> via NativeChannelId) and DMs are unchanged, so no working channel/DM broadcast entry silently stops matching.
  • msteams monitor-handler + config-doctor suites: 10 files / 114 tests pass.

Update: DM/channel scope

  • Doctor migrates only group-chat legacy keys (msteams:conversation:19:…@thread.v2). DM (a:…) and channel keys are left alone and still resolve through their existing lookup; a new inbound→dispatch regression proves a personal-conversation msteams:conversation:<dm> entry still fans out to both agents.
  • Docs now scope the bare-id form to group chats and spell out the retained channel and DM forms.

Real behaviour proof

Environment: Linux cloud VM; scratch Gateway with the Teams plugin and the plugin's loopback Bot Framework QA stand-in (no Teams tenant), QA mock model, agents main + helper, group chat 19:[email protected]. Tokens and activity ids redacted. Branch head 93e544b.

Before (main, no conversation.routePeer)

Step Agents replying Session(s) History
no broadcast main agent:main:msteams:group:19:[email protected] PROOF-BEFORE
broadcast["msteams:<chat>"] (documented) main only, key ignored same bare key PROOF-BEFORE, PROOF-DURING
broadcast["msteams:conversation:<chat>"] (legacy) main + helper agent:{main,helper}:msteams:group:conversation:19:[email protected] only PROOF-LEGACY; main's room history is gone from context
entry removed main bare key again PROOF-BEFORE, PROOF-DURING, PROOF-AFTER (PROOF-LEGACY stranded on the prefixed session)

After (this branch)

Step Agents replying Session(s) main history
no broadcast main agent:main:msteams:group:19:[email protected] PROOF-BEFORE
broadcast["msteams:<chat>"] main + helper main unchanged; helper agent:helper:msteams:group:19:[email protected] PROOF-BEFORE, PROOF-DURING
entry removed main same bare key PROOF-BEFORE, PROOF-DURING, PROOF-AFTER

Upgrade / data-model compatibility from [email protected] + @openclaw/[email protected]

  • On 2026.10.9, one group turn under broadcast["msteams:conversation:19:[email protected]"] stored history on the conversation-prefixed session keys.
  • Switched the same state dir to this checkout. First openclaw doctor --fix upgraded the agent databases (schema v25 → v39) and printed:
    Moved broadcast."msteams:conversation:19:[email protected]" → broadcast."msteams:19:[email protected]".
  • Second openclaw doctor --fix: no further broadcast change (idempotent).
  • chat.history on both original keys still returns the stored turn (user PROOF-LEGACY reply exactly: PROOF-LEGACY, assistant PROOF-LEGACY). Existing transcripts load under their original keys; they are not silently merged into the bare-id session.

@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: msteams Channel integration: msteams size: S labels Nov 2, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR aligns Teams group-chat broadcast identity with ordinary routing and migrates legacy broadcast keys through Doctor.

Example: Enable broadcast for Teams chat 19:[email protected] with agents main and helper.

  • Before: The documented key is ignored; the conversation-prefixed key starts main in a separate session.
  • After: Both agents respond, while main continues using agent:main:msteams:group:19:[email protected].

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with meaningful boundary regressions, Gateway and upgrade evidence, successful exact-head gates, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The current-head body records scratch-Gateway results through the Teams Bot Framework QA transport: both participants reply, main retains its session and history across broadcast addition/removal, and latest-stable Doctor migration is idempotent with original histories still readable; this proves the routing/storage boundary without claiming live Teams-tenant coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Adding Teams group-chat broadcast either does nothing with the documented key or moves the routed agent into a different conversation history.
Reason: The change restores the existing room-session contract without adding options or changing channel-thread sharing policy.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR repairs a current Teams group-chat routing defect, addresses the earlier compatibility findings, and introduces no actionable defect found in this review.

Priority: P2
Reviewed head: 93e544b042455d5580cf5b737b6cd5766108cc75

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Teams inbound handler supplies admitted conversation facts to core broadcast dispatch, which selects participants and constructs their session keys; Doctor normalizes existing configuration before runtime use.

flowchart TD
  A[Teams activity] --> B[Teams admission and routing]
  B --> C[Inbound conversation facts]
  C --> D[Core broadcast dispatch]
  E[Doctor normalized config] --> D
  D --> F[Participant sessions and replies]
Loading

Technical review

Best possible solution:

Use the existing Teams route-peer contract and plugin-owned Doctor migration to keep group-chat identity consistent without rewriting historical sessions.

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

Current source exposes the complete identity mismatch, and the contributor supplies failing-base regression results and Gateway observations; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the Teams producer through an existing SDK contract, retains other conversation identities, and places compatibility repair in the existing Doctor owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 28a93a00ac7a.

Provenance checked

  • Channel-qualified broadcast lookup and session identity keeps the original intent (fdc1e31: The merged feature introduced shared multi-agent dispatch using channel-qualified room identities and isolated participant sessions.)
  • Teams inbound conversation facts changes intended behavior with a stated reason (45c636b: The refactor placed dispatch in the admitted Teams handler while preserving existing behavior; this commit carried the omitted peer facts rather than establishing their original introduction.)
  • Plugin-owned Doctor normalization keeps the original intent (b57e493: Historical webhook compatibility must remain repairable during upgrades; the patch retains that normalization before applying broadcast repair.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 93a9fa4 adds extensions/msteams/src/monitor-handler/message-handler.ts:206 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 93a9fa4562b6; files: extensions/msteams/src/monitor-handler/message-handler.ts)
  • Jimmy Puckett: Raw commit 19ac119 adds extensions/msteams/src/monitor-handler/message-handler.ts:210 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 19ac11902cdc; files: extensions/msteams/src/monitor-handler/message-handler.ts)
  • Vincent Koc: Raw commit 12d3a2f adds extensions/msteams/src/monitor-handler/message-handler.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 12d3a2f2f6ff; files: extensions/msteams/src/monitor-handler/message-handler.ts)

PR surface

Source +75, Tests +174, Docs +3. Total +252 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 79 4 +75
Tests 1 174 0 +174
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 257 5 +252

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +79/-4 lines; tests +174 lines Growth supports the routing repair and required legacy-key migration, with distinct regressions for continuity, migration, collisions, and retained DM behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #190740
Summary: This PR addresses the group-chat broadcast peer mismatch established by the linked issue.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The defect affects a bounded Teams broadcast workflow and splits conversation context without evidence of a broader outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (4 earlier review cycles)
  • reviewed 2026-11-02T02:38:35.347Z sha c6c8a3e :: needs real behavior proof before merge. :: [P1] Migrate working Teams broadcast keys before changing their lookup identity
  • reviewed 2026-11-02T03:08:00.125Z sha d7aa32f :: needs real behavior proof before merge. :: [P1] Finish collision repairs instead of retaining a matching legacy key | [P1] Preserve existing channel broadcast keys during the peer cutover
  • reviewed 2026-11-02T03:31:17.667Z sha 65b54ef :: needs real behavior proof before merge. :: [P1] Keep migrated DM broadcast keys reachable at runtime | [P3] Scope the bare conversation-ID documentation to group chats
  • reviewed 2026-11-02T03:50:46.896Z sha 93e544b :: needs real behavior proof before merge. :: none

Reviewed November 1, 2026, 11:47 PM ET / November 2, 2026, 04:47 UTC (Revision 5).

@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 2, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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: 🧂 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 2, 2026

This branch has not been deployed

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

Labels

channel: msteams Channel integration: msteams docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant