chore: removed the too many tools warning (#9974)
This commit is contained in:
@@ -26,7 +26,6 @@ import { scanRecipe } from '../recipe';
|
||||
import type { Recipe } from '../recipe';
|
||||
import { UserInput } from '../types/message';
|
||||
import RecipeActivities from './recipes/RecipeActivities';
|
||||
import { useToolCount } from './alerts/useToolCount';
|
||||
import { getThinkingMessage, getTextAndImageContent } from '../types/message';
|
||||
import ParameterInputModal from './ParameterInputModal';
|
||||
import { substituteParameters } from '../utils/parameterSubstitution';
|
||||
@@ -275,8 +274,6 @@ export default function BaseChat({
|
||||
}
|
||||
}, [messages.length]);
|
||||
|
||||
const toolCount = useToolCount(sessionId);
|
||||
|
||||
// Listen for global scroll-to-bottom requests (e.g., from MCP UI prompt actions)
|
||||
useEffect(() => {
|
||||
const handleGlobalScrollRequest = () => {
|
||||
@@ -532,7 +529,6 @@ export default function BaseChat({
|
||||
recipe={recipe}
|
||||
recipeAccepted={!hasNotAcceptedRecipe}
|
||||
initialPrompt={initialPrompt}
|
||||
toolCount={toolCount || 0}
|
||||
sessionModel={sessionModel}
|
||||
sessionProvider={sessionProvider}
|
||||
sessionLoaded={sessionLoaded}
|
||||
|
||||
@@ -81,9 +81,7 @@ const removeQueuedMessage = (messages: QueuedMessage[], messageId: string): Queu
|
||||
|
||||
const MAX_IMAGES_PER_MESSAGE = 10;
|
||||
|
||||
// Constants for token and tool alerts
|
||||
const TOKEN_LIMIT_DEFAULT = 128000; // fallback for custom models that the backend doesn't know about
|
||||
const TOOLS_MAX_SUGGESTED = 60; // max number of tools before we show a warning
|
||||
|
||||
const getContextAlertType = (totalTokens: number, tokenLimit: number): AlertType => {
|
||||
const percentage = tokenLimit ? (totalTokens / tokenLimit) * 100 : 0;
|
||||
@@ -117,15 +115,6 @@ const i18n = defineMessages({
|
||||
id: 'chatInput.contextWindow',
|
||||
defaultMessage: 'Context window',
|
||||
},
|
||||
tooManyTools: {
|
||||
id: 'chatInput.tooManyTools',
|
||||
defaultMessage:
|
||||
'Too many tools can degrade performance.\nTool count: {toolCount} (recommend: {recommended})',
|
||||
},
|
||||
viewExtensions: {
|
||||
id: 'chatInput.viewExtensions',
|
||||
defaultMessage: 'View extensions',
|
||||
},
|
||||
waitingForImages: {
|
||||
id: 'chatInput.waitingForImages',
|
||||
defaultMessage: 'Waiting for images to save...',
|
||||
@@ -192,7 +181,6 @@ interface ChatInputProps {
|
||||
recipeId?: string | null;
|
||||
recipeAccepted?: boolean;
|
||||
initialPrompt?: string;
|
||||
toolCount: number;
|
||||
append?: (message: Message) => void;
|
||||
onWorkingDirChange?: (newDir: string) => Promise<void> | void;
|
||||
inputRef?: React.RefObject<HTMLTextAreaElement | null>;
|
||||
@@ -229,7 +217,6 @@ export default function ChatInput({
|
||||
recipeId: _recipeId,
|
||||
recipeAccepted,
|
||||
initialPrompt,
|
||||
toolCount,
|
||||
append: _append,
|
||||
onWorkingDirChange,
|
||||
inputRef,
|
||||
@@ -658,7 +645,7 @@ export default function ChatInput({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [effectiveModel, effectiveProvider, configModel, configProvider]);
|
||||
|
||||
// Handle tool count alerts and token usage
|
||||
// Handle token usage alerts
|
||||
useEffect(() => {
|
||||
clearAlerts();
|
||||
|
||||
@@ -681,24 +668,9 @@ export default function ChatInput({
|
||||
});
|
||||
}
|
||||
|
||||
// Add tool count alert if we have the data
|
||||
if (toolCount !== null && toolCount > TOOLS_MAX_SUGGESTED) {
|
||||
addAlert({
|
||||
type: AlertType.Warning,
|
||||
message: intl.formatMessage(i18n.tooManyTools, {
|
||||
toolCount,
|
||||
recommended: TOOLS_MAX_SUGGESTED,
|
||||
}),
|
||||
action: {
|
||||
text: intl.formatMessage(i18n.viewExtensions),
|
||||
onClick: () => setView('extensions'),
|
||||
},
|
||||
autoShow: false, // Don't auto-show tool count warnings
|
||||
});
|
||||
}
|
||||
// We intentionally omit setView as it shouldn't trigger a re-render of alerts
|
||||
// Keep alert recalculation scoped to token state changes.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [totalTokens, toolCount, tokenLimit, isTokenLimitLoaded, addAlert, clearAlerts]);
|
||||
}, [totalTokens, tokenLimit, isTokenLimitLoaded, addAlert, clearAlerts]);
|
||||
|
||||
// Cleanup effect for component unmount - prevent memory leaks
|
||||
useEffect(() => {
|
||||
|
||||
@@ -146,7 +146,6 @@ export default function Hub({
|
||||
onFilesProcessed={() => {}}
|
||||
messages={[]}
|
||||
disableAnimation={false}
|
||||
toolCount={0}
|
||||
onWorkingDirChange={setWorkingDir}
|
||||
inputRef={inputRef}
|
||||
nextChatExtensionDraft={draftForMenu}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getTools } from '../../api';
|
||||
|
||||
// TODO(Douwe): return this as part of the start agent request
|
||||
export const useToolCount = (sessionId: string) => {
|
||||
const [toolCount, setToolCount] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchTools = async () => {
|
||||
try {
|
||||
const response = await getTools({ query: { session_id: sessionId } });
|
||||
setToolCount(response.error || !response.data ? 0 : response.data.length);
|
||||
} catch (err) {
|
||||
console.error('Error fetching tools:', err);
|
||||
setToolCount(0);
|
||||
}
|
||||
};
|
||||
|
||||
fetchTools();
|
||||
}, [sessionId]);
|
||||
|
||||
return toolCount;
|
||||
};
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "Send"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "Too many tools can degrade performance. Tool count: {toolCount} (recommend: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "Transcribing..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "View/Edit Recipe"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "View extensions"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "Waiting for cancellation to finish"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "Enviar"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "Demasiadas herramientas pueden degradar el rendimiento. Cantidad de herramientas: {toolCount} (recomendado: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "Transcribiendo..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "Ver/Editar Receta"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "Ver extensiones"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "Esperando a que finalice la cancelación"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "भेजें"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "बहुत सारे उपकरण प्रदर्शन को ख़राब कर सकते हैं. उपकरण संख्या: {toolCount} (अनुशंसा: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "प्रतिलेखन..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "रेसिपी देखें/संपादित करें"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "एक्सटेंशन देखें"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "रद्दीकरण समाप्त होने की प्रतीक्षा की जा रही है"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "送信"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "ツールが多すぎるとパフォーマンスが低下する可能性があります。ツール数: {toolCount}(推奨: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "文字起こし中..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "レシピを表示/編集"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "拡張機能を表示"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "キャンセルの完了を待機中"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "보내기"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "도구가 너무 많으면 성능이 저하될 수 있습니다. 도구 수: {toolCount} (권장: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "음성을 텍스트로 변환 중..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "레시피 보기/편집"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "익스텐션 보기"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "취소가 완료될 때까지 기다리는 중"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "Отправить"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "Слишком много инструментов может снизить производительность. Количество инструментов: {toolCount} (рекомендуется: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "Расшифровка..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "Просмотреть/изменить рецепт"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "Просмотреть расширения"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "Ожидание завершения отмены"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "Gönder"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "Çok fazla araç performansı düşürebilir. Takım sayısı: {toolCount} (önerilen: {recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "Metne dönüştürülüyor..."
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "Tarifi Görüntüle/Düzenle"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "Uzantıları görüntüle"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "İptalin tamamlanması bekleniyor"
|
||||
},
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
"chatInput.send": {
|
||||
"defaultMessage": "发送"
|
||||
},
|
||||
"chatInput.tooManyTools": {
|
||||
"defaultMessage": "工具过多会降低性能。工具数量:{toolCount}(建议:{recommended})"
|
||||
},
|
||||
"chatInput.transcribing": {
|
||||
"defaultMessage": "转写中…"
|
||||
},
|
||||
@@ -200,9 +197,6 @@
|
||||
"chatInput.viewEditRecipe": {
|
||||
"defaultMessage": "查看/编辑配方"
|
||||
},
|
||||
"chatInput.viewExtensions": {
|
||||
"defaultMessage": "查看扩展"
|
||||
},
|
||||
"chatInput.waitingForCancellation": {
|
||||
"defaultMessage": "正在等待取消完成"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user