Repository navigation
fix(channels-intelligence): Teams thread history (getHistory + getMessages) - #5969
Conversation
…Messages
getHistory was Slack-only: it keyed off threadTs and returned [] for any route
without one, so a Teams route ({adapter:'teams', tenantId, conversationId})
never hit /api/channels/history. That starved BOTH history paths on Teams --
agent.messages seeding (conversationStore.getOrCreate) and the read_thread tool
-- so the agent always reported "no earlier messages" / "no image in thread".
- getHistory is now adapter-aware (mirrors conversationKeyFromReplyTarget's
per-adapter switch): Slack keys off teamId/channel/threadTs; Teams sends
adapter=teams + tenantId + conversationId, matching app-api's
teams:{tenantId}:{conversationId} thread_key. The /api/channels/history route
already accepts this shape. Slack query order is unchanged.
- Add getMessages to the adapter so thread.getMessages() (the read_thread tool)
reads reconstructed history via the transport and maps it to ThreadMessage[].
Without it Thread.getMessages() returns [] and thread-reading tools see
nothing even when history exists.
Adds tests for the Teams getHistory query and the missing-id short-circuit.
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
|
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
|
Nice, tightly-scoped fix — the Requested change — add a test for the new Minor (optional):
|
Addresses review on #5969: - Add getMessages tests: string content, content-part array (text parts joined, non-text contributes ""), and role→isBot/user derivation; plus the no-getHistory transport case returning []. - Log on the unexpected getMessages catch (matches conversationStore's seeding path) instead of degrading to [] silently — HttpDeliverySource already swallows its own fetch failures, so this outer catch only fires on a real throw. - Fold the duplicated role boolean (isBot computed once, drives both fields).
|
Thanks — all addressed in Requested change — Minor:
Text-only flattening: confirmed intentional — check-types clean, all 117 package tests green. |
BenTaylorDev
left a comment
There was a problem hiding this comment.
Reviewed the diff — clean, well-scoped fix. Making getHistory adapter-aware (Slack path byte-for-byte unchanged, Teams as a new guarded branch) and adding getMessages so Thread.getMessages() stops returning [] both address the "no earlier messages" / "no image" symptom at the right layer. getMessages mirrors the conversationStore seeding read for consistency, correct URLSearchParams encoding of the Teams conversationId, and solid test coverage (Teams query shape, missing-field short-circuit, string + content-part mapping, no-getHistory fallback).
No correctness issues found. The minor polish items (content-part join double-space, read_thread JSDoc wording, duplicate per-turn getHistory fetch) are non-blocking and tracked in OSS-488, so nothing here should hold the merge. The app-api /api/channels/history Teams thread_key counterpart lands in the Intelligence repo — flagging only so the two land compatibly (description says it was verified against a live managed Teams bot).
I bless the code with a glad heart.
#6035) ## What Follow-up nit from [PR #5969](#5969) review ([OSS-488](https://linear.app/copilotkit/issue/OSS-488)). Fixes the `getMessages` JSDoc in `packages/channels-intelligence/src/intelligence-adapter.ts`, which oversold image support. The comment cited *"what was in the image"* as a `read_thread` use case, but image/file parts contribute **no text** in this mapping — `read_thread` is text-only by design. Image *content* reaches the model only via `conversationStore`'s seeding of `agent.messages`. The comment now says so explicitly instead of implying `read_thread` can see image content. Comment-only change — no runtime/API behavior change, so no changeset. ## Scope of OSS-488 The ticket listed three nits; this PR addresses the one still actionable: - **#1 (double-space when joining content parts)** — ✅ already resolved on `main` (the `.filter(Boolean).join(" ")` fix + updated test landed via the OSS-476 CR round). Nothing to do. - **#2 (JSDoc oversells image support)** — ✅ **this PR**. - **#3 (duplicate `getHistory` fetch per turn)** — intentionally **deferred**. A per-turn memo would need turn-scoped caching with a clear-on-turn-start hook; without one it risks serving stale history — a correctness regression on something the ticket itself rates "acceptable for an on-demand tool." Not worth it here. The **known limitation** (speakers collapse to `user`/`bot` because upstream `AgentMessage` carries no names) is unchanged and not actionable at this layer. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Problem
On the managed Teams path the agent always reported "no earlier messages" / "I don't see the image in this thread."
HttpDeliverySource.getHistorywas Slack-only: it keyed offthreadTsand returned[]for any route without one. A Teams route is{ adapter: 'teams', tenantId, conversationId }(nothreadTs), so it short-circuited before making any request — starving both history mechanisms on Teams:agent.messagesseeding (conversationStore.getOrCreate), andread_threadtool (viathread.getMessages()).Fix
getHistoryis now adapter-aware (mirrorsconversationKeyFromReplyTarget's per-adapter switch): Slack keys offteamId/channel/threadTs; Teams sendsadapter=teams+tenantId+conversationId, matching app-api'steams:{tenantId}:{conversationId}thread_key. app-api's/api/channels/historyroute already accepts this shape. Slack query and order are unchanged.getMessagesto the adapter sothread.getMessages()(theread_threadtool) reads reconstructed history via the transport and maps it toThreadMessage[]. Without itThread.getMessages()returns[]and thread-reading tools (summaries, "what was in the image") see nothing even when history exists.Tests
getHistoryquery, and the missing-tenantId/conversationIdshort-circuit (no request).channels-intelligencetests pass;check-typesclean.Notes
Verified end-to-end against a live managed Teams bot as a dist patch before porting to source (history seeding +
read_threadboth start returning the thread's messages). The app-api counterpart (Teams ingress: reactions, inline-media/Graph file ingest, slash commands) is a separate PR in the Intelligence repo.