fix(agent): honor suggested-questions limit parameter

Treat limit as the authoritative upper bound instead of clamping it down
to the agent's Starters.Count, so ?limit=N no longer always returns 6.

Fixes #2238
This commit is contained in:
Jack Wang
2026-07-23 21:23:31 +08:00
committed by lyingbug
parent e0b6a71503
commit 43839f7830
10 changed files with 152 additions and 19 deletions
+4 -2
View File
@@ -225,9 +225,11 @@ export async function getEmbedChunkById(channelId: string, token: string, chunkI
)
}
export async function getEmbedSuggestedQuestions(channelId: string, token: string, limit = 6) {
export async function getEmbedSuggestedQuestions(channelId: string, token: string, limit?: number) {
// Omit limit to let the channel agent's configured starter count apply.
const qs = typeof limit === 'number' && limit > 0 ? `?limit=${limit}` : ''
return get<{ success: boolean; data: { questions: SuggestedQuestion[] } }>(
`/api/v1/embed/${channelId}/suggested-questions?limit=${limit}`,
`/api/v1/embed/${channelId}/suggested-questions${qs}`,
{ headers: { Authorization: `Embed ${token}` } },
)
}
+6 -2
View File
@@ -418,8 +418,12 @@ export const useSettingsStore = defineStore("settings", {
return this.settings.selectedFiles || [];
},
/** Scope for suggested-questions API (KB / file / tag @mentions). */
getSuggestedQuestionsParams(limit = 6) {
/**
* Scope for suggested-questions API (KB / file / tag @mentions).
* Leave `limit` undefined to let the backend apply the agent's configured
* starter count; pass a number only to request a specific count.
*/
getSuggestedQuestionsParams(limit?: number) {
const selectedKBs = this.getSelectedKnowledgeBases();
const selectedFiles = this.getSelectedFiles();
const tags = this.settings.selectedTags || [];
+1 -1
View File
@@ -314,7 +314,7 @@ const fetchSuggestedQuestions = async () => {
try {
const agentId = useSettingsStoreInstance.selectedAgentId;
if (!agentId) return;
const res = await getSuggestedQuestions(agentId, useSettingsStoreInstance.getSuggestedQuestionsParams(6));
const res = await getSuggestedQuestions(agentId, useSettingsStoreInstance.getSuggestedQuestionsParams());
if (fetchId === suggestedQuestionsFetchId) {
suggestedQuestions.value = res?.data?.questions || [];
}
+1 -1
View File
@@ -139,7 +139,7 @@ const fetchSuggestedQuestions = async () => {
try {
const agentId = settingsStore.selectedAgentId;
if (!agentId) return;
const res = await getSuggestedQuestions(agentId, settingsStore.getSuggestedQuestionsParams(6));
const res = await getSuggestedQuestions(agentId, settingsStore.getSuggestedQuestionsParams());
if (fetchId === suggestedQuestionsFetchId) {
sqCardsRevealed.value = false;
sqRenderKey.value++;
+1 -1
View File
@@ -315,7 +315,7 @@ const fetchSuggestedQuestions = async () => {
}
suggestedLoading.value = true
try {
const res = await getEmbedSuggestedQuestions(props.channelId, props.token, 6)
const res = await getEmbedSuggestedQuestions(props.channelId, props.token)
suggestedQuestions.value = res?.data?.questions || []
} catch {
suggestedQuestions.value = []