Skip to content

feat(msteams): Auto-inject thread context when message arrives as thread reply #54932

@mrbrl

Description

@mrbrl

Problem

When a user replies in a Teams channel thread, the bot receives only the new message — it has no context of the preceding thread messages. Combined with session pruning (session.maintenance.pruneAfter), this means agents responding in channel threads frequently lose all context, even from messages sent hours earlier.

Current behavior

  • Bot receives reply in thread
  • Session may have been pruned (6h default)
  • Agent has zero context of what the thread was about
  • Agent asks user to repeat/clarify, which is a poor UX

Expected behavior

When a message arrives as a thread reply (has replyToId / is in a conversation thread), the msteams plugin should:

  1. Fetch the root message + preceding N replies via Graph API (teams/{id}/channels/{id}/messages/{id}/replies)
  2. Inject them as conversation history / context in the session
  3. Configurable limit (e.g., msteams.config.threadContextMessages: 10)

Workaround

We built a Graph API thread reader script and are injecting thread context manually in cron job prompts. This is fragile and doesn't cover interactive channel use.

Environment

  • OpenClaw 2026.3.13
  • MSTeams plugin (Bot Framework)
  • App-only Graph API credentials with ChannelMessage.Read.All working

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions