Skip to content

fix(msteams): pass teamId into inbound route resolution#39352

Closed
hddevteam wants to merge 1 commit intoopenclaw:mainfrom
hddevteam:fix/msteams-teamid-routing
Closed

fix(msteams): pass teamId into inbound route resolution#39352
hddevteam wants to merge 1 commit intoopenclaw:mainfrom
hddevteam:fix/msteams-teamid-routing

Conversation

@hddevteam
Copy link
Copy Markdown

Summary

  • pass teamId into MSTeams inbound resolveAgentRoute() calls
  • add a regression test covering channel messages with a team-scoped route

Root cause

The MSTeams inbound handler already reads activity.channelData?.team?.id, and the shared routing layer already supports teamId-scoped bindings.

However, the handler did not forward teamId when calling resolveAgentRoute(). That caused channel messages to fall back to the default agent instead of matching configured team/channel bindings.

This looks like an implementation bug rather than an intentional product restriction because:

  • the routing API explicitly supports teamId
  • the route matcher already has a binding.team path
  • the MSTeams handler already extracts and uses teamId elsewhere
  • forwarding teamId restores the expected routing behavior without changing the routing model

Validation

  • added a regression test asserting that channel messages pass teamId into route resolution
  • ran:
    • pnpm test:extensions -- --run extensions/msteams/src/monitor-handler/message-handler.authz.test.ts
  • result:
    • 261 passed, including extensions/msteams/src/monitor-handler/message-handler.authz.test.ts

Impact

This fixes MSTeams channel routing for deployments that rely on team-scoped bindings, so channel messages can resolve to the intended isolated agent instead of dropping back to the default agent.

Copilot AI review requested due to automatic review settings March 8, 2026 01:38
@openclaw-barnacle openclaw-barnacle bot added channel: msteams Channel integration: msteams size: S labels Mar 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR fixes a missing teamId argument in the MSTeams inbound message handler's resolveAgentRoute() call. The value was already being extracted from activity.channelData?.team?.id and used for channel-gate logic, but was not forwarded to the routing layer — causing channel messages to always fall back to the default agent instead of matching team-scoped bindings.

Changes:

  • message-handler.ts: adds teamId to the resolveAgentRoute() call (single-line fix).
  • message-handler.authz.test.ts: adds a regression test that constructs a channel message with channelData.team.id, intercepts the resolveAgentRoute call via a throwing mock, and asserts the mock was invoked with the correct teamId, channel, and peer fields.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted bug fix with no behavioural regressions for DM or group-chat flows.
  • The fix is a single-line addition of an already-extracted variable to an existing function call. The routing layer already accepts teamId as an optional parameter, so passing undefined for non-channel messages is handled correctly. The added test directly validates the reported regression scenario, and the unchanged code paths (DMs, group chats) are not affected.
  • No files require special attention.

Last reviewed commit: c017acb

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes MSTeams inbound routing for channel messages by ensuring the extracted teamId is forwarded into the shared routing layer, enabling team-scoped bindings to match as intended (instead of falling back to the default agent).

Changes:

  • Forward teamId into core.channel.routing.resolveAgentRoute() in the MSTeams inbound message handler.
  • Add a regression test asserting teamId is passed for channel messages with channelData.team.id.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/msteams/src/monitor-handler/message-handler.ts Passes teamId into route resolution so team-scoped bindings can match for channel messages.
extensions/msteams/src/monitor-handler/message-handler.authz.test.ts Adds a regression test validating teamId is included in route resolution inputs for channel messages.

@hddevteam hddevteam force-pushed the fix/msteams-teamid-routing branch from c017acb to 2eb03ac Compare March 8, 2026 01:50
@hddevteam
Copy link
Copy Markdown
Author

CI status note

The currently failing CI jobs are unrelated to this PR's changes:

  • check (Check types and lint and oxfmt): Fails due to a formatting issue in src/cli/daemon-cli/lifecycle-core.ts introduced by upstream commit 2c7fb549 (Config: fail closed invalid config loads Config: fail closed invalid config loads #39071). This issue is present on main itself — pnpm format:check src/cli/daemon-cli/lifecycle-core.ts fails on upstream HEAD.

  • secrets and the sporadic checks-windows/checks (bun) failures also originate from upstream and are unrelated to the two files changed in this PR.

The jobs directly relevant to this fix all pass:

  • checks (node, extensions, pnpm test:extensions) — covers message-handler.authz.test.ts
  • checks (node, test, pnpm test) (all shards except the unrelated bun/windows flake)
  • checks (node, protocol, pnpm protocol:check)

I'll re-sync once the upstream format issue is resolved.

@hddevteam hddevteam force-pushed the fix/msteams-teamid-routing branch 2 times, most recently from 0e05dcc to 84808ed Compare March 8, 2026 04:20
The Teams message handler already reads the incoming teamId and the routing layer already supports team-scoped bindings, but the handler did not forward teamId into resolveAgentRoute(). That caused channel messages to fall back to the default agent instead of matching configured team/channel bindings.\n\nThis change forwards teamId during inbound route resolution and adds a regression test that asserts channel messages pass teamId into the routing call.
@hddevteam hddevteam force-pushed the fix/msteams-teamid-routing branch from 84808ed to 5812719 Compare March 8, 2026 13:13
@BradGroux BradGroux self-assigned this Mar 10, 2026
@BradGroux
Copy link
Copy Markdown
Contributor

Hi @hddevteam — thanks for the submission. I’m the new Microsoft Teams maintainer for OpenClaw. Please give me a day or two to work through the open Teams backlog. Also, join the Twitter community for daily MS Teams feedback + updates: https://x.com/i/communities/2031170403607974228

@BradGroux
Copy link
Copy Markdown
Contributor

Superseded by #50214.

@BradGroux BradGroux closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: msteams Channel integration: msteams size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants