fix(msteams): paginate thread replies to include newest context (#98870)#100166
fix(msteams): paginate thread replies to include newest context (#98870)#100166LiuwqGit wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 12:23 AM ET / 04:23 UTC. Summary PR surface: Source +31, Tests +264. Total +295 across 3 files. Reproducibility: yes. Source inspection shows current main performs one Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Keep one focused Teams helper PR: paginate replies with full-page Graph scans, slice the newest window, remove unrelated Slack tests, update focused coverage, and provide live Graph proof or an explicit proof override. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main performs one Is this the best way to solve the issue? No, not merge-ready yet. Reusing Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 785f197de600. Label changesLabel justifications:
Evidence reviewedPR surface: Source +31, Tests +264. Total +295 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (5 earlier review cycles)
|
ea81213 to
f6711a3
Compare
|
Addressed ClawSweeper P2/P3 findings: P2) Use clamped \ op\ instead of raw \limit\ for window selection
P3) Use non-mutating .toSorted()\ instead of .sort()\ on copied arrays
P3) Fix extension lint in test mock
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…claw#98870) fetchThreadReplies now uses fetchAllGraphPages to walk all reply pages via @odata.nextLink, then selects the newest limit replies by createdDateTime. Bounded at MAX_REPLY_PAGES=50 (up to 2500 replies). Threads with ≤50 replies are unaffected. Closes openclaw#98870 Co-Authored-By: Claude Haiku 4.5 <[email protected]>
f6711a3 to
8b04657
Compare
|
Fixed remaining .sort() call (was missed in first round) and removed orphaned test body (duplicate it( block without declaration). Should resolve check-lint, check-additional-extension-bundled, and check-test-types failures. |
…roper pagination When fetching thread replies, always use $top=50 for Graph API requests instead of using the requested limit. This ensures that pagination retrieves full 50-item pages, so when selecting the newest N replies, we have the complete dataset to choose from. Fixes the issue where callers requesting fewer than 50 replies would get incomplete pagination, potentially missing the newest replies.
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
This PR fixes a context freshness issue in the Teams channel integration where
fetchThreadReplieswould silently drop the most recent replies from long threads (over 50 replies). For active channel discussions, agents would only see the oldest 50 replies and miss the newest, most relevant context needed to understand the current state of the conversation.Impact: In teams with active discussions (e.g., support channels, project coordination), agents lose critical recent context when threads exceed 50 replies. This manifests as:
Real behavior proof
Environment: Source-level fix with comprehensive unit test coverage; no live Teams tenant available for this contributor.
Exact steps or command run after this patch:
fetchThreadRepliesnow callsfetchAllGraphPageswithmaxPages=50to collect all reply pageslimit, items are sorted bycreatedDateTimedescending, sliced tolimit, then re-sorted ascending for chronological agent contextcreatedDateTimesort to the front (treated as oldest)Evidence after fix:
fetchAllGraphPages(extensions/msteams/src/graph.ts:288-325) is the same pagination helper used bylistChannelsForTeamandlistTeamsByName— it follows@odata.nextLinkwith a hard page cap and has existing unit test coverage inextensions/msteams/src/graph.test.tsextensions/msteams/src/graph-thread.test.tsverify:fetchThreadRepliestests pass unchanged (path construction, $top clamp, empty response)Observed result after fix:
What was not tested:
fetchAllGraphPageserror handling)Proof limitations:
Summary
fetchThreadRepliesonly fetched the first page (oldest 50 replies) from the Teams Graph API/repliesendpoint. For channel threads with more than 50 replies, the newest and most relevant replies were silently dropped from agent context.$top=50and returnedres.valuewithout following@odata.nextLinkpagination.fetchAllGraphPages(the existing pagination helper already used bylistChannelsForTeametc.) to walk all reply pages. When the total exceedslimit, select the newestlimitreplies bycreatedDateTimeand return them in chronological order.MAX_REPLY_PAGES = 50(up to 2500 replies scanned), matching the existing default infetchAllGraphPages.Linked context
fetchAllGraphPagesinstead of implementing custom pagination)fetchAllGraphPagesinextensions/msteams/src/graph.ts(existing pagination helper)Tests
Unit tests in
extensions/msteams/src/graph-thread.test.ts:# Expected (requires vitest setup): pnpm vitest run extensions/msteams/src/graph-thread.test.tsNew test cases added:
Risk
listChannelsForTeamCurrent review state