Skip to content

fix(msteams): keep structured sends in channel threads - #117516

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-teams-thread-send-20260801
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-teams-thread-send-20260801

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Closes #117514

What Problem This Solves

Fixes an issue where Microsoft Teams users receiving polls, presentation cards, or Adaptive Cards as channel-thread replies would see those messages posted at channel top level instead of inside the requested thread.

Why This Change Was Made

The proactive send context now owns one closed destination: either a top-level conversation or a channel thread with its exact activity root. Every direct activity kind consumes that resolved context, so text, media, consent cards, native file cards, presentation cards, and polls share one thread-routing decision. The outbound poll adapter also preserves its standard threadId through the existing target normalizer.

The pinned Microsoft Teams SDK 2.0.14 routes proactive creation by ref.conversation.id; activityId is not used for that path. The fix therefore carries the Connector ;messageid=<root> identity in the resolved conversation reference instead of reconstructing it in individual senders.

Top-level channel sends, group chats, and personal chats remain on the base conversation. There is no protocol, config, persistence, dependency, migration, or public SDK change.

User Impact

Teams polls and structured cards now remain attached to the channel conversation that requested them. Operators no longer get detached top-level posts for thread-scoped actions, while ordinary top-level channels, group chats, and DMs keep their existing routing.

Before

POST /v3/conversations/19:[email protected]/activities

After

POST /v3/conversations/19:[email protected];messageid=thread-root-1/activities

Evidence

  • Before the repair, 5 new SDK-boundary cases failed and 38 existing cases passed.
  • Focused structured-send proof passed 43/43 after the repair.
  • The full Microsoft Teams plugin suite passed 1,366/1,366 across 89 files on Blacksmith Testbox tbx_01kyyzz83vdyzy947dgq4zkg0z, run https://github.com/openclaw/openclaw/actions/runs/30706587571.
  • The same Testbox command passed the complete changed gate: formatting, production/test types, lint, boundaries, dead code, database-first, and import cycles.
  • The boundary tests use the real @microsoft/teams.apps / @microsoft/teams.api 2.0.14 HTTP client and assert exact paths and activity payloads for threaded channels, top-level channels, group chats, and DMs.
  • Direct dependency inspection confirmed ActivitySender.send passes ref.conversation.id to the conversation client, which interpolates it into /v3/conversations/{id}/activities.
  • The branch rebased cleanly onto origin/main at ea2e7f46a69744a6d1b346db20043a3388f9b001; none of the six touched files had mainline drift.
  • Final P1 Codex autoreview had no accepted/actionable finding. Its repeated claim that the explicit thread target lacked a channel guard was rejected because send-context.ts already requires conversationType === "channel"; group/personal routes return the closed top-level variant.
  • git diff --check is clean.
  • Production delta: +35/-62 (net -27); tests: +174/-23.

The final current-main Testbox request remained queued without allocation for five minutes and was stopped; direct AWS fallback was unavailable because this machine lacks managed broker login. The earlier patch-identical Testbox proof is under 24 hours old, and exact-head hosted CI is required before landing.

No live tenant credentials were used; the real SDK HTTP boundary deterministically proves the routing contract.

Release-note context: Microsoft Teams polls and structured cards now stay in their requested channel threads.

AI-assisted: yes. The implementation was independently reviewed, checked against the pinned SDK source, and remotely validated.

@openclaw-barnacle openclaw-barnacle Bot added channel: msteams Channel integration: msteams size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 16:56
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:01 PM ET / 17:01 UTC.

ClawSweeper review

What this changes

The PR resolves each Microsoft Teams proactive structured-send destination once, then uses that destination for adaptive cards, polls, consent cards, and native file cards so channel replies remain in their requested thread.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for explicit maintainer handling: the source-backed patch fixes the reported Microsoft Teams thread-routing gap through the proper proactive-send owner boundary, and no blocking correctness or security defect was found. The branch is cleanly mergeable but behind current main, with exact-head hosted checks still in progress and a protected maintainer label requiring human merge judgment.

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

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused root-cause repair with direct SDK-boundary evidence and no supported blocking finding; remaining merge handling is the protected-label and exact-head-check gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.
Evidence reviewed 6 items Current-main defect boundary: Current main resolves reply policy but its direct proactive-activity helper sends the stored reference without carrying a thread activity identifier, so adaptive-card and poll creates cannot select the thread-qualified conversation identity.
Canonical owner-boundary repair: The PR makes the proactive context a closed top-level-or-thread target, then passes that context to every direct activity sender; this avoids each activity kind independently reconstructing thread policy.
SDK routing contract: The existing proactive wrapper converts a thread activity identifier into ;messageid=&lt;root> and supplies the resulting ref.conversation.id to the SDK conversation activity client, matching the endpoint-selection mechanism exercised by the tests.
Findings None None.
Security None None.

How this fits together

The Microsoft Teams plugin turns an outbound target plus stored conversation reference into a proactive Bot Framework activity. That activity is sent through the Teams SDK to a conversation endpoint, where a channel-thread root must be encoded in the conversation identity while top-level channels, group chats, and personal chats retain the base identity.

flowchart LR
  A[Outbound message or poll] --> B[Target normalizer]
  B --> C[Proactive send context]
  C --> D{Channel thread?}
  D -->|Yes| E[Thread-qualified conversation]
  D -->|No| F[Base conversation]
  E --> G[Teams SDK activity request]
  F --> G
  G --> H[Microsoft Teams delivery]
Loading

Decision needed

Question Recommendation
After the exact-head hosted checks finish, should this protected Microsoft Teams routing repair be merged with its SDK-boundary proof as the acceptance evidence? Merge after exact-head checks: Accept the canonical context-owned routing repair once the in-progress hosted checks are green for this head.

Why: The maintainer label requires explicit human handling even though the patch is focused, cleanly mergeable, and has no actionable code-review finding.

Before merge

  • Resolve merge risk (P1) - This changes the Bot Framework conversation address used for direct structured activity creation; the route matrix is covered at the SDK HTTP boundary, but exact-head hosted validation should finish before a maintainer merges the protected PR.
Agent review details

Security

None.

PR surface

Source -27, Tests +151. Total +124 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 35 62 -27
Tests 3 174 23 +151
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 209 85 +124

Review metrics

Metric Value Why it matters
Structured routing matrix 4 destination classes covered The real Teams API-client boundary test checks threaded channels, top-level channels, group chats, and personal chats before direct activity creation.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117514
Summary: This PR is the focused candidate repair for the canonical report about Teams cards and polls escaping channel threads.

Members:

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

Merge-risk options

Maintainer options:

  1. Wait for exact-head channel checks (recommended)
    Merge after the current head’s hosted validation completes, retaining the existing four-destination SDK-boundary test matrix as the regression guard.

Technical review

Best possible solution:

Keep one closed proactive destination in the Microsoft Teams send context, retain the base destination for non-thread channel and chat routes, and merge after the exact-head checks confirm the same focused boundary coverage.

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

Yes, at source level: a stored channel reference with a thread root reaches direct adaptive-card or poll creation without a thread-qualified conversation identity on current main. The proposed boundary test captures the real pinned SDK client’s exact create-activity path for that case.

Is this the best way to solve the issue?

Yes. Carrying the resolved destination through the proactive send context is the narrowest maintainable fix because the policy and thread root remain coupled for every direct activity kind, instead of adding sender-specific URL reconstruction.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a deterministic Microsoft Teams message-placement regression with limited channel-specific blast radius.
  • add merge-risk: 🚨 message-delivery: The PR changes which Bot Framework conversation endpoint receives structured activities, so an incorrect classification could misplace messages despite otherwise successful delivery.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.

Label justifications:

  • P2: This is a deterministic Microsoft Teams message-placement regression with limited channel-specific blast radius.
  • merge-risk: 🚨 message-delivery: The PR changes which Bot Framework conversation endpoint receives structured activities, so an incorrect classification could misplace messages despite otherwise successful delivery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and inspected regression test provide after-fix SDK-boundary proof: the real pinned Teams API client emits the expected thread-qualified create path while the matrix verifies unaffected destination classes.

Evidence

What I checked:

  • Current-main defect boundary: Current main resolves reply policy but its direct proactive-activity helper sends the stored reference without carrying a thread activity identifier, so adaptive-card and poll creates cannot select the thread-qualified conversation identity. (extensions/msteams/src/send.ts:451, 581688143a97)
  • Canonical owner-boundary repair: The PR makes the proactive context a closed top-level-or-thread target, then passes that context to every direct activity sender; this avoids each activity kind independently reconstructing thread policy. (extensions/msteams/src/send-context.ts:35, fbad9cec9f50)
  • SDK routing contract: The existing proactive wrapper converts a thread activity identifier into ;messageid=<root> and supplies the resulting ref.conversation.id to the SDK conversation activity client, matching the endpoint-selection mechanism exercised by the tests. (extensions/msteams/src/sdk-proactive.ts:66, 581688143a97)
  • Boundary proof covers routing variants: The proposed test runs the real pinned Teams API client against a captured HTTP transport and asserts request paths and payloads for threaded channels, top-level channels, group chats, and personal chats across structured senders. (extensions/msteams/src/send.threaded-attachments.test.ts:87, fbad9cec9f50)
  • Feature provenance: The direct proactive-send and send-context path appears to date to the original Microsoft Teams implementation commit; blame attributes the relevant baseline lines to that commit, making this PR a focused completion of that routing model rather than a parallel path. (extensions/msteams/src/send-context.ts:56, a172857acc75)
  • Current-main and release position: The PR head is not contained in current main; its base is contained, and a three-way merge produces no conflict. No local release tag contains the proposed head, so it remains an unmerged, unreleased fix candidate rather than an already-implemented change. (extensions/msteams/src/send.ts:419, fbad9cec9f50)

Likely related people:

  • zengLingbiao: Blame attributes the baseline reply-policy and direct-send code to the commit that introduced the Microsoft Teams proactive routing implementation. (role: introduced proactive-send path; confidence: high; commits: a172857acc75; files: extensions/msteams/src/send-context.ts, extensions/msteams/src/send.ts, extensions/msteams/src/sdk-proactive.ts)
  • steipete: History shortlog shows substantial prior work in the affected Teams send and SDK-routing files, in addition to the proposed focused repair. (role: recent area contributor; confidence: medium; commits: fbad9cec9f50; files: extensions/msteams/src/send-context.ts, extensions/msteams/src/send.ts, extensions/msteams/src/outbound.ts)

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.

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready review is complete for exact head fbad9cec9f50a1d5b6b69f10c9a901adeca743f2.

The broken invariant was split destination ownership: the Teams send context exposed reply policy separately from the stored reference, so text/media and one recent attachment repair carried the thread root while polls and presentation/Adaptive Cards sent direct activities to the base conversation. The fix makes the destination a closed context variant—top-level, or channel thread plus exact activity root—and every direct activity sender consumes it. The poll adapter now preserves the standard outbound threadId. Production changes +35/-62 (net -27); no protocol, config, persistence, dependency, migration, permission, or service-URL contract changed.

Proof:

  • Before the fix, 5 new SDK-boundary cases failed; after the fix, 43/43 focused cases passed.
  • Blacksmith Testbox tbx_01kyyzz83vdyzy947dgq4zkg0z, run https://github.com/openclaw/openclaw/actions/runs/30706587571, passed the full Microsoft Teams plugin suite (1,366/1,366 across 89 files) and the complete changed gate.
  • The tests use the real pinned @microsoft/teams.apps / @microsoft/teams.api 2.0.14 HTTP client and prove threaded channels, top-level channels, group chats, and DMs for cards and polls. Direct SDK source inspection confirms create routing uses ref.conversation.id in /v3/conversations/{id}/activities.
  • Exact-head hosted CI https://github.com/openclaw/openclaw/actions/runs/30709232501 is fully green, including openclaw/ci-gate.
  • Repo-native review artifacts validate READY FOR /prepare-pr with zero findings; git diff --check is clean.
  • Two P1 autoreview passes repeated a false claim that the channel guard was missing. The branch explicitly requires recipient.threadId && conversationType === "channel"; group/personal contexts return the closed top-level variant, and neither direct activity nor text/media paths attach a suffix for them. No actionable review finding remains.

The final current-main Testbox allocation stayed queued without a runner for five minutes and was stopped; direct AWS fallback lacked managed broker login. No touched file changed on main during the clean rebase, and the patch-identical Testbox proof is under 24 hours old. Exact-head hosted CI supplies the final current-head integration proof.

ClawSweeper workflow https://github.com/openclaw/clawsweeper/actions/runs/30709286195 completed successfully for this head but left only its start placeholder, so it published no findings or rank-up moves and no bot approval is claimed.

@steipete
steipete merged commit 17625e5 into main Aug 1, 2026
155 of 166 checks passed
@steipete
steipete deleted the codex/autoqa-teams-thread-send-20260801 branch August 1, 2026 17:07
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(msteams): keep structured sends in channel threads This is item 3/3 in the current shard. Shard 6/45.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

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

Labels

channel: msteams Channel integration: msteams maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Teams cards and polls escape channel threads

1 participant