Skip to content

[Bug]: Teams thread context omits newer replies when a channel thread has more than 50 replies #98870

Description

@qingminglong

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Teams channel thread context only fetches the first 50 oldest replies, so newer replies are omitted when a thread has more than 50 replies.

Steps to reproduce

  1. Configure the Microsoft Teams plugin for a channel message thread with more than 50 replies.
  2. Trigger the monitor path for a reply in that long thread.
  3. Inspect the thread context passed to the agent.

Expected behavior

The thread context should include the newest relevant replies from the thread. The Teams Graph replies endpoint exposes additional reply pages through @odata.nextLink, so OpenClaw should follow pagination instead of stopping at the oldest first page.

Actual behavior

fetchThreadReplies requests /messages/{messageId}/replies?$top=50... once and returns only res.value. The source comment notes that Graph returns replies oldest-first and that the newest replies are silently omitted for threads with more than 50 replies.

OpenClaw version

Current main at 4010b81, source-level repro.

Operating system

Not OS-specific.

Install method

Source checkout / pnpm dev.

Model

Not provider-specific; source-level Teams channel runtime path.

Provider / routing chain

Not provider-specific; source-level Teams channel runtime path.

Additional provider/model setup details

NOT_ENOUGH_INFO

Logs, screenshots, and evidence

Source evidence:

  • extensions/msteams/src/graph-thread.ts clamps replies to $top=50 and returns only res.value.
  • The same file documents that Graph replies are oldest-first and that @odata.nextLink can retrieve more replies.
  • extensions/msteams/src/monitor-handler/message-handler.ts uses fetchThreadReplies(...) for agent thread context.
  • Adjacent Teams Graph helpers already follow @odata.nextLink for paginated Graph collections.

Duplicate search:

  • gh search issues --repo openclaw/openclaw --state open --match title,body -- "Teams graph thread replies nextLink" returned no open results.
  • gh search prs --repo openclaw/openclaw --state open --match title,body -- "Teams graph thread replies nextLink" returned no open results.

Focused regression test idea:

  • Mock a replies response with @odata.nextLink, return newer replies on the next page, and assert fetchThreadReplies follows pagination and returns the newest limited set.

Impact and severity

Affected: Microsoft Teams channel users with long reply threads.
Severity: Medium; agent context can miss the most recent conversation state.
Frequency: Always when the relevant context falls after the first 50 oldest replies.
Consequence: The agent may answer using stale thread context.

Additional information

NOT_ENOUGH_INFO

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions