Skip to content

fix(teams): read the real message behind quotes and message links - #674

Merged
patroza merged 2 commits into
fork/devfrom
fix/teams-resolve-linked-messages
Nov 24, 2026
Merged

patroza merged 2 commits into
fork/devfrom
fix/teams-resolve-linked-messages

Conversation

@patroza

@patroza patroza commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

When someone in Teams quotes a message or pastes a message link and mentions the bot, Teams only sends a cut-off preview ("…the delivery notice wasn…"). The bot passed that preview to T3 and never saw the real message.

Mentions now resolve those references through Microsoft Graph, using the app token the gateway already has:

  • What is detected (teams/referencedMessages.ts):

    • Quoted replies (<blockquote itemtype="http://schema.skype.com/Reply" itemid=…>).
    • Teams message links (teams.microsoft.com / teams.cloud.microsoft /l/message/…) in the text or any attachment. This includes link-preview cards.
    • Chat links and channel links both work. A channel link uses groupId and parentMessageId.
  • What goes into the T3 turn:

    • The full message text, with author and time.
    • Its inline images, attached as turn images.
    • The names of its files (not opened).
    • Up to 8 earlier messages from that chat, or from that channel thread including its root.
    • Everything is marked as untrusted quoted content.
  • The cut-off preview: once the real message is resolved, the old "Quoted Teams attachment text" preview is dropped.

  • Wiring: inboundImages.ts runs this inside loadTeamsTurnImages. Images share its dedupe and caps. The section goes into the turn note with its own 12k cap.

  • Your own text is kept: the mention's text stays the request, with the referenced message added below it as quoted content.

  • Watched group chats load only the quoted message's text, with no earlier messages and no images, because their weekly log thread already has those (referencedDetail: "text").

Permissions: no new ones. Channels use ChannelMessage.Read.Group. I checked live that the gateway's credentials can list, get, read replies, and read hosted contents in the Omega Scanner channel (all 200). Chats use ChatMessage.Read.Chat, which is in the installed package.

Tests: referencedMessages.test.ts covers link and quote parsing, the chat message with images, files and context, the channel reply-to-root fallback, and an unreadable message. All 126 Teams tests pass, and typecheck is clean.

🤖 Generated with Claude Code

github-actions Bot and others added 2 commits November 24, 2026 12:43
Teams only sends a short preview when someone quotes a message or pastes a
message link, so the agent saw "the delivery notice wasn…" and nothing more.
Mentions now resolve quoted replies and Teams message links through Graph:
the full text, its inline images (attached to the T3 turn), the names of its
files, and up to eight earlier messages from that chat or channel thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Their weekly log thread already holds the earlier messages and images, so
loading them again for a quote only duplicates the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@patroza
patroza merged commit dbe3462 into fork/dev Nov 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant