fix(msteams): pass teamId and teamName to resolveAgentRoute() [AI-assisted]#50214
Conversation
Greptile SummaryThis PR adds Key findings:
Confidence Score: 2/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/msteams/src/monitor-handler/message-handler.ts
Line: 385-389
Comment:
**`teamName` in `peer` is a type error and is silently ignored by routing**
`RoutePeer` is typed as `{ kind: ChatType; id: string }` with no `teamName` field (`src/routing/resolve-route.ts:21-24`). Passing `teamName` here is an excess property that TypeScript should reject on the object literal.
More importantly, even if TypeScript accepted it, the routing function immediately strips `peer` down to only `kind` and `id`:
```typescript
// src/routing/resolve-route.ts:617-622
const peer = input.peer
? {
kind: normalizeChatType(input.peer.kind) ?? input.peer.kind,
id: normalizeId(input.peer.id),
}
: null;
```
`teamName` is never read from `peer` anywhere in `resolveAgentRoute`. There is no `teamName` field in `ResolveAgentRouteInput` either.
The `teamId` addition at line 384 is the correct and functional fix — it maps to `ResolveAgentRouteInput.teamId` (line 34) and is actively used for team-scoped binding resolution. The `teamName` in `peer` should either be removed (if not needed by the published package's routing logic), or `RoutePeer` needs to be extended to include `teamName?: string` if the `2026.3.13` package updated the type.
```suggestion
peer: {
kind: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
id: isDirectMessage ? senderId : conversationId,
},
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix(msteams): pass t..." |
The upstream 2026.3.13 package correctly extracts teamId and teamName from activity.channelData but was not forwarding them into the resolveAgentRoute() call. This caused team-scoped agent routing to fail in group/channel conversations where team context is required. Fixes: resolveAgentRoute missing teamId + peer.teamName fields
RoutePeer is typed as { kind: ChatType; id: string } with no teamName
field. Passing teamName was an excess property that TypeScript rejects,
and it was stripped by routing anyway. The teamId addition is the sole
functional fix — it maps to ResolveAgentRouteInput.teamId and is used
for team-scoped binding resolution.
Addresses Greptile review comment.
7660c62 to
b3c3bcd
Compare
slbteam08
left a comment
There was a problem hiding this comment.
Accepted — removed teamName from peer. RoutePeer has no teamName field per the published type definitions; teamId at the top level is the correct and only functional change needed.
…aw#50214) thanks @slbteam08 Signed-off-by: samzong <[email protected]>
The upstream 2026.3.13 package correctly extracts teamId and teamName from activity.channelData but was not forwarding them into the resolveAgentRoute() call. This caused team-scoped agent routing to fail in group/channel conversations where team context is required.
Fixes: resolveAgentRoute missing teamId + peer.teamName fields
Summary
resolveAgentRoute()in the MSTeams message handler was not receivingteamIdorpeer.teamName, even though both values were correctlyextracted from
activity.channelDataearlier in the same function.This caused team-scoped agent routing to silently fail in group and
channel conversations where team context is needed to resolve the
correct agent.
Root Cause
In
extensions/msteams/src/monitor-handler/message-handler.ts, thecall to
resolveAgentRoute()was missing two fields:const route = core.channel.routing.resolveAgentRoute({ cfg, channel: "msteams", + teamId, peer: { kind: isDirectMessage ? "direct" : isChannel ? "channel" : "group", id: isDirectMessage ? senderId : conversationId, + teamName, }, });Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.Agent routing in MSTeams group/channel conversations now correctly resolves when team context is present. No change for DMs.
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
openclaw.jsonwithmatch.teamIdattribute setExpected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Verified against the published [email protected] package, which contains the correct implementation. This PR aligns the source with what is already shipped. Lightly tested — the fix matches the published package exactly.
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.AI Disclosure