Skip to content

Commit c8127a6

Browse files
committed
fix(microsoft-teams): surface pagination truncation via hasMore flag
- add hasMore output (derived from @odata.nextLink presence) to list_teams, list_chats, list_channels, list_chat_members so agents can detect truncated results instead of trusting the count field as a total - do NOT add $top to list_teams' joinedTeams request — Graph docs explicitly state this endpoint does not support OData query parameters, so it would silently no-op
1 parent e3c49c3 commit c8127a6

6 files changed

Lines changed: 30 additions & 0 deletions

File tree

apps/sim/blocks/blocks/microsoft_teams.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
515515
chatCount: { type: 'number', description: 'Total number of chats' },
516516
channels: { type: 'json', description: 'Array of channels in the team' },
517517
channelCount: { type: 'number', description: 'Total number of channels' },
518+
hasMore: {
519+
type: 'boolean',
520+
description: 'Whether Graph indicated additional pages beyond this response',
521+
},
518522
type: { type: 'string', description: 'Type of Teams message' },
519523
id: { type: 'string', description: 'Unique message identifier' },
520524
timestamp: { type: 'string', description: 'Message timestamp' },

apps/sim/tools/microsoft_teams/list_channels.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export const listChannelsTool: ToolConfig<
3737
success: { type: 'boolean', description: 'Whether the listing was successful' },
3838
channels: { type: 'array', description: 'Array of channels in the team' },
3939
channelCount: { type: 'number', description: 'Total number of channels' },
40+
hasMore: {
41+
type: 'boolean',
42+
description: 'Whether Graph indicated additional pages beyond this response',
43+
},
4044
},
4145

4246
request: {
@@ -74,6 +78,7 @@ export const listChannelsTool: ToolConfig<
7478
output: {
7579
channels,
7680
channelCount: channels.length,
81+
hasMore: Boolean(data['@odata.nextLink']),
7782
metadata: {
7883
teamId: params?.teamId || '',
7984
},

apps/sim/tools/microsoft_teams/list_chat_members.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const listChatMembersTool: ToolConfig<
3636
success: { type: 'boolean', description: 'Whether the listing was successful' },
3737
members: { type: 'array', description: 'Array of chat members' },
3838
memberCount: { type: 'number', description: 'Total number of members' },
39+
hasMore: {
40+
type: 'boolean',
41+
description: 'Whether Graph indicated additional pages beyond this response',
42+
},
3943
},
4044

4145
request: {
@@ -73,6 +77,7 @@ export const listChatMembersTool: ToolConfig<
7377
output: {
7478
members,
7579
memberCount: members.length,
80+
hasMore: Boolean(data['@odata.nextLink']),
7681
metadata: {
7782
chatId: params?.chatId || '',
7883
},

apps/sim/tools/microsoft_teams/list_chats.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const listChatsTool: ToolConfig<MicrosoftTeamsToolParams, MicrosoftTeamsL
2828
success: { type: 'boolean', description: 'Whether the listing was successful' },
2929
chats: { type: 'array', description: 'Array of chats the user is part of' },
3030
chatCount: { type: 'number', description: 'Total number of chats' },
31+
hasMore: {
32+
type: 'boolean',
33+
description: 'Whether Graph indicated additional pages beyond this response',
34+
},
3135
},
3236

3337
request: {
@@ -61,6 +65,7 @@ export const listChatsTool: ToolConfig<MicrosoftTeamsToolParams, MicrosoftTeamsL
6165
output: {
6266
chats,
6367
chatCount: chats.length,
68+
hasMore: Boolean(data['@odata.nextLink']),
6469
},
6570
}
6671
},

apps/sim/tools/microsoft_teams/list_teams.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ export const listTeamsTool: ToolConfig<MicrosoftTeamsToolParams, MicrosoftTeamsL
2828
success: { type: 'boolean', description: 'Whether the listing was successful' },
2929
teams: { type: 'array', description: 'Array of teams the user is a member of' },
3030
teamCount: { type: 'number', description: 'Total number of teams' },
31+
hasMore: {
32+
type: 'boolean',
33+
description: 'Whether Graph indicated additional pages beyond this response',
34+
},
3135
},
3236

3337
request: {
38+
// Note: GET /me/joinedTeams does not support OData query parameters ($top, etc.) per Graph docs:
39+
// https://learn.microsoft.com/en-us/graph/api/user-list-joinedteams
3440
url: () => 'https://graph.microsoft.com/v1.0/me/joinedTeams',
3541
method: 'GET',
3642
headers: (params) => {
@@ -58,6 +64,7 @@ export const listTeamsTool: ToolConfig<MicrosoftTeamsToolParams, MicrosoftTeamsL
5864
output: {
5965
teams,
6066
teamCount: teams.length,
67+
hasMore: Boolean(data['@odata.nextLink']),
6168
},
6269
}
6370
},

apps/sim/tools/microsoft_teams/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export interface MicrosoftTeamsListMembersResponse extends ToolResponse {
142142
output: {
143143
members: MicrosoftTeamsMember[]
144144
memberCount: number
145+
hasMore?: boolean
145146
metadata: {
146147
teamId?: string
147148
channelId?: string
@@ -162,6 +163,7 @@ export interface MicrosoftTeamsListTeamsResponse extends ToolResponse {
162163
output: {
163164
teams: MicrosoftTeamsTeamSummary[]
164165
teamCount: number
166+
hasMore: boolean
165167
}
166168
}
167169

@@ -179,6 +181,7 @@ export interface MicrosoftTeamsListChatsResponse extends ToolResponse {
179181
output: {
180182
chats: MicrosoftTeamsChatSummary[]
181183
chatCount: number
184+
hasMore: boolean
182185
}
183186
}
184187

@@ -195,6 +198,7 @@ export interface MicrosoftTeamsListChannelsResponse extends ToolResponse {
195198
output: {
196199
channels: MicrosoftTeamsChannelSummary[]
197200
channelCount: number
201+
hasMore: boolean
198202
metadata: {
199203
teamId: string
200204
}

0 commit comments

Comments
 (0)