Skip to content

fix(msteams): restore missing channel thread context - #128901

Merged
steipete merged 1 commit into
mainfrom
codex/qa-msteams-thread-graph-query-20260824
Aug 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-msteams-thread-graph-query-20260824

Conversation

@steipete

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users replying in a Microsoft Teams channel thread would receive answers without the original message or earlier replies when Microsoft Graph rejects unsupported query parameters. The bot also silently lost the parent author's name and its "Replying to @…" context event, leaving short replies such as "yes" without the conversation they answer.

Why This Change Was Made

Microsoft Graph's get chatMessage API supports no OData query parameters, and its list channel message replies API supports only $top, capped at 50. Request the parent without query parameters and request replies with the existing bounded $top only. The existing chat-message sibling already follows the same contract. Authentication, SSRF protection, URL encoding, sender visibility, shared deadlines, and pagination behavior remain unchanged; production code decreases by three lines.

User Impact

Microsoft Teams channel replies once again include both the original question and prior thread messages, preserve the parent author's identity, and enqueue the existing parent-context event. Existing channel permissions, sender allowlists, request timeouts, and reply limits are unaffected.

Evidence

  • Checked-in regression failed against the original code through the actual Teams Graph owner and guarded HTTP transport: the parent returned undefined after HTTP 400, and the reply request rejected with ProviderHttpError 400.
  • The identical regression now passes with a parent URL containing no query and a replies URL containing only $top=50.
  • End-to-end production message-handler proof changed from no thread history, no author, and no parent event to Alice: the original question plus Bob: the prior decision, author Alice, and Replying to @Alice: the original question.
  • Independent real loopback HTTP confirmed both routes return HTTP 200, preserve encoded identifiers and bearer authentication, retain the shared request deadline and SSRF guard, and clamp a requested 200 replies to 50.
  • Owner Graph, thread, and message-handler suites: 60 tests passed.
  • Independent owner, actual Graph transport, message-handler, sender-visibility, and deadline suites: 84 tests passed.
  • Focused extension lint, formatting, and both authenticated uncommitted and committed reviews passed; production delta -3 lines.

@clawsweeper

clawsweeper Bot commented Aug 24, 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 channel: msteams Channel integration: msteams size: XS maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 23:31
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 7:36 PM ET / 23:36 UTC.

ClawSweeper review

What this changes

This PR removes unsupported query parameters from Microsoft Teams channel-parent and thread-reply Graph requests, restoring thread context supplied to the agent.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-labeled PR open for normal maintainer handling. The owner-level correction is coherent and no patch defect was found, but exact-head CI is still running and the Microsoft Graph contract could not be independently rechecked from this network-isolated review environment.

Priority: P1
Reviewed head: e9e0df993b18a342e06393aee20b5a8a021e645b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with credible regression coverage and no identified correctness or security defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is authored by a MEMBER, so the external-contributor proof gate does not apply; its stated loopback and handler evidence was not re-executed in this read-only review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is authored by a MEMBER, so the external-contributor proof gate does not apply; its stated loopback and handler evidence was not re-executed in this read-only review.
Evidence reviewed 6 items Current-main failure path: Current main appends $select=id,from,body,createdDateTime to both the channel-parent request and the replies request; parent-fetch errors become undefined, while the caller uses those results to construct thread context.
Owner-boundary repair: The PR-head owner keeps encoded identifiers, the shared deadline, and the $top bound while removing $select from the two channel-thread paths.
Caller and downstream behavior: The channel handler obtains the parent and replies together, preserves either successful result, and uses the parent plus replies to enqueue the parent event and format agent context.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/msteams/src/graph.test.ts extensions/msteams/src/graph-thread.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs extensions/msteams/src/graph.test.ts extensions/msteams/src/graph-thread.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128901-T9EyLO/target$ node scripts/run-vitest.mjs extensions/msteams/src/graph.test.ts extensions/msteams/src/g
raph-thread.test.ts
node scripts/run-vitest.mjs extensions/msteams/src/graph.test.ts extensions/msteams/src/graph-thread.test.ts
[test] starting test/vitest/vitest.extension-msteams.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128901-T9EyLO/target

 ✓  extension-msteams  extensions/msteams/src/graph-thread.test.ts (26 tests) 140ms
 ✓  extension-msteams  extensions/msteams/src/graph.test.ts (26 tests) 61ms

 Test Files  2 passed (2)
      Tests  52 passed (52)
   Start at  23:37:49
   Duration  12.10s (transform 10.82s, setup 2.22s, import 10.61s, tests 202ms, environment 0ms)

[test] passed 1 Vitest shard in 18.19s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128901-T9EyLO/target$ node scripts/run-vitest.mjs extensions/msteams/src/graph.test.ts extensions/msteams/src/g
raph-thread.test.ts
































Assertions:

  • PASS expect_output: graph.test.ts
  • PASS expect_output: graph-thread.test.ts

How this fits together

Incoming Microsoft Teams channel replies fetch their parent message and prior replies through the plugin’s Graph client before building the context delivered to the agent. Those Graph results also supply the parent author used for the reply-context event.

flowchart LR
  A[Teams channel reply] --> B[Incoming message handler]
  B --> C[Thread context lookup]
  C --> D[Microsoft Graph requests]
  D --> E[Parent and earlier replies]
  E --> F[Agent context and parent event]
Loading

Before merge

  • Resolve merge risk (P1) - Microsoft Graph documentation and a real tenant were unreachable from this read-only environment, so the external query contract was not independently revalidated; exact-head CI is also still in progress.
  • Complete next step (P2) - No repair lane is needed: no actionable patch defect was found, and the remaining checks are normal maintainer validation for a protected maintainer-authored PR.
Agent review details

Security

None.

PR surface

Source -3, Tests +34. Total +31 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 5 -3
Tests 2 37 3 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 39 8 +31

Review metrics

Metric Value Why it matters
Production versus test LOC production -3 (2 added, 5 removed); tests +34 (37 added, 3 removed) The bug fix removes query construction at the Graph owner while its focused regression coverage grows without adding production surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the owner-local request correction, then complete exact-head CI and record a maintainer-owned Graph documentation or tenant check before landing.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the owner-local request correction, then complete exact-head CI and record a maintainer-owned Graph documentation or tenant check before landing.

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

No independent high-confidence live reproduction was available: current main clearly sends the disputed queries and drops failed parent fetches, but Graph documentation and a tenant were unreachable from this environment.

Is this the best way to solve the issue?

Yes at the code level: repairing the Graph request owner preserves the existing encoding, deadline, sender-visibility, and bounded-reply behavior instead of compensating downstream.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The PR repairs a broken Microsoft Teams channel reply workflow that otherwise omits conversation context from agent turns.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by a MEMBER, so the external-contributor proof gate does not apply; its stated loopback and handler evidence was not re-executed in this read-only review.

Label justifications:

  • P1: The PR repairs a broken Microsoft Teams channel reply workflow that otherwise omits conversation context from agent turns.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is authored by a MEMBER, so the external-contributor proof gate does not apply; its stated loopback and handler evidence was not re-executed in this read-only review.

Evidence

What I checked:

  • Current-main failure path: Current main appends $select=id,from,body,createdDateTime to both the channel-parent request and the replies request; parent-fetch errors become undefined, while the caller uses those results to construct thread context. (extensions/msteams/src/graph-thread.ts:42, b71a09fd8a3e)
  • Owner-boundary repair: The PR-head owner keeps encoded identifiers, the shared deadline, and the $top bound while removing $select from the two channel-thread paths. (extensions/msteams/src/graph-thread.ts:42, e9e0df993b18)
  • Caller and downstream behavior: The channel handler obtains the parent and replies together, preserves either successful result, and uses the parent plus replies to enqueue the parent event and format agent context. (extensions/msteams/src/monitor-handler/thread-context.ts:145, e9e0df993b18)
  • Regression coverage: The added owner-transport test rejects unsupported query parameters and verifies the parent request has none while replies retain only $top=50. It is a guarded-transport mock, not an independently observed Graph tenant response. (extensions/msteams/src/graph.test.ts:220, e9e0df993b18)
  • Feature provenance: Blame attributes the current-main query-bearing lines to the recent transcript-display commit; the original channel-thread Graph feature dates to the merged feature commit for pull request 51643. (extensions/msteams/src/graph-thread.ts:42, 59a92211801e)
  • External-contract inspection gap: The PR supplies Microsoft Graph documentation links, but direct inspection of learn.microsoft.com and live GitHub reads were unavailable because DNS resolution failed in this review environment.

Likely related people:

  • shakkernerd: Current-main blame attributes both query-bearing request lines to this contributor’s recent area commit. (role: recent area contributor; confidence: high; commits: 59a92211801e; files: extensions/msteams/src/graph-thread.ts)
  • sudie-codes: Introduced the channel-thread Graph history feature in the historical feature commit linked to pull request 51643. (role: feature introducer; confidence: high; commits: 8c852d86f759; files: extensions/msteams/src/graph-thread.ts, extensions/msteams/src/monitor-handler/thread-context.ts)
  • steipete: Appears repeatedly in Graph-thread module history and authored the established plain chat-message Graph sibling path. (role: recent area contributor; confidence: medium; commits: e84a0dde175e, f6b990124353; files: extensions/msteams/src/graph-thread.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 merged commit 4c8c228 into main Aug 24, 2026
176 checks passed
@steipete
steipete deleted the codex/qa-msteams-thread-graph-query-20260824 branch August 24, 2026 23:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

1 participant