Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ ${
${
platformEventKind === 'automation'
? `- Execute the automation prompt now. Use integrations directly when sufficient, and launch a task only when repository or workspace execution is actually required. The configured model is a delegated-task default, not the Fast inference model.
- When the automation asks for launchable suggested tasks and this is a Slack or Discord report, put each concrete follow-up in the closeout's \`suggestions\` array. Keep the report summary in \`message\`; do not render suggestion cards or reaction instructions as inline prose because the delivery layer adds them.
- When the automation asks for launchable suggested tasks and this is a Slack, Discord, Teams, or Telegram report, put each concrete follow-up in the closeout's \`suggestions\` array. Keep the report summary in \`message\`; do not render suggestion cards or launch instructions as inline prose because the delivery layer adds them.
- If launchable suggestions are unavailable on the current surface, keep follow-ups as ordinary report text and do not promise reaction-triggered launching.
`
: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,13 +1417,14 @@ export async function answerFastAgentQuestion({
(args.purpose !== 'closeout' ||
!platformEvent ||
platformEventKind !== 'automation' ||
(conversation.surface !== 'slack' &&
conversation.surface !== 'discord'))
!['slack', 'discord', 'teams', 'telegram'].includes(
conversation.surface,
))
) {
return {
success: false,
error:
'Launchable suggestions are available only on Slack or Discord automation closeouts.',
'Launchable suggestions are available only on chat automation closeouts.',
};
}
if (
Expand Down
92 changes: 92 additions & 0 deletions packages/sdk/src/server/lib/fast-agent-parent-event.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 78 additions & 4 deletions packages/sdk/src/server/lib/fast-agent-parent-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {
appendFastAutomationSuggestionInstruction,
postFastAutomationSuggestionsToDiscord,
postFastAutomationSuggestionsToSlack,
postFastAutomationSuggestionsToTeams,
postFastAutomationSuggestionsToTelegram,
} from './fast-automation-suggestions';

import {
Expand Down Expand Up @@ -1068,12 +1070,25 @@ async function createTeamsFastAgentParentTurn(params: {
conversation,
serviceUrl,
}),
postReply: async ({ message, imageArtifactIds = [], kickoff }) => {
postReply: async ({
message,
imageArtifactIds = [],
suggestions = [],
kickoff,
}) => {
const images = await buildSelectedImages({
artifactIds: imageArtifactIds,
event: params.event,
});
const text = `${message}\n\n${buildFastSessionReplyFooterText({ provider: 'teams', sessionId: params.parent.sessionId })}`;
const reportMessage =
params.event.type === 'automation_triggered' && !kickoff
? appendFastAutomationSuggestionInstruction(
message,
'teams',
suggestions.length > 0,
)
: message;
const text = `${reportMessage}\n\n${buildFastSessionReplyFooterText({ provider: 'teams', sessionId: params.parent.sessionId })}`;
if (
params.event.type === 'automation_triggered' &&
params.event.rootMessageId &&
Expand All @@ -1092,6 +1107,19 @@ async function createTeamsFastAgentParentTurn(params: {
conversation,
messageId: params.event.rootMessageId,
});
if (suggestions.length > 0) {
await postFastAutomationSuggestionsToTeams({
provider,
channelId: conversation.replyTarget.channelId,
serviceUrl,
...(conversation.replyTarget.threadId
? { threadId: conversation.replyTarget.threadId }
: {}),
eventId: params.event.eventId,
createdByUserId: session.userId,
suggestions,
});
}
params.onReplyPosted();
return { messageId: params.event.rootMessageId };
}
Expand All @@ -1108,6 +1136,23 @@ async function createTeamsFastAgentParentTurn(params: {
textFormat: 'markdown',
images,
});
if (
params.event.type === 'automation_triggered' &&
!kickoff &&
suggestions.length > 0
) {
await postFastAutomationSuggestionsToTeams({
provider,
channelId: conversation.replyTarget.channelId,
serviceUrl,
...(conversation.replyTarget.threadId
? { threadId: conversation.replyTarget.threadId }
: {}),
eventId: params.event.eventId,
createdByUserId: session.userId,
suggestions,
});
}
await recordFastAgentConversationMessageBestEffort({
sessionId: session.id,
conversation,
Expand Down Expand Up @@ -1151,20 +1196,49 @@ async function createTelegramFastAgentParentTurn(params: {
userId: session.userId,
conversation,
}),
postReply: async ({ message, imageArtifactIds = [] }) => {
postReply: async ({
message,
imageArtifactIds = [],
suggestions = [],
kickoff,
}) => {
const images = await buildSelectedImages({
artifactIds: imageArtifactIds,
event: params.event,
});
const reportMessage =
params.event.type === 'automation_triggered' && !kickoff
? appendFastAutomationSuggestionInstruction(
message,
'telegram',
suggestions.length > 0,
)
: message;
const posted = await provider.postMessage({
channelId: conversation.replyTarget.channelId,
...(conversation.replyTarget.threadId
? { threadId: conversation.replyTarget.threadId }
: {}),
text: `${message}\n\n${buildFastSessionReplyFooterText({ provider: 'telegram', sessionId: params.parent.sessionId })}`,
text: `${reportMessage}\n\n${buildFastSessionReplyFooterText({ provider: 'telegram', sessionId: params.parent.sessionId })}`,
textFormat: 'markdown',
images,
});
if (
params.event.type === 'automation_triggered' &&
!kickoff &&
suggestions.length > 0
) {
await postFastAutomationSuggestionsToTelegram({
provider,
channelId: conversation.replyTarget.channelId,
...(conversation.replyTarget.threadId
? { threadId: conversation.replyTarget.threadId }
: {}),
eventId: params.event.eventId,
createdByUserId: session.userId,
suggestions,
});
}
params.onReplyPosted();
return { messageId: posted.messageId };
},
Expand Down
Loading
Loading