diff --git a/memento-note/context/notebooks-context.tsx b/memento-note/context/notebooks-context.tsx index 7cd6e1d..d697da1 100644 --- a/memento-note/context/notebooks-context.tsx +++ b/memento-note/context/notebooks-context.tsx @@ -84,7 +84,12 @@ export function NotebooksProvider({ children, initialNotebooks = [] }: Notebooks const [isLoading, setIsLoading] = useState(true) const [isMovingNote, setIsMovingNote] = useState(false) const [error, setError] = useState(null) - const { triggerRefresh } = useNoteRefresh() // Get triggerRefresh from context + const { triggerRefresh, refreshKey } = useNoteRefresh() + + // Recharge les carnets à chaque fois qu'une note est modifiée/supprimée + useEffect(() => { + if (refreshKey > 0) loadNotebooks() + }, [refreshKey, loadNotebooks]) // ===== DERIVED STATE ===== const currentLabels = useMemo(() => { diff --git a/memento-note/lib/ai/services/agent-executor.service.ts b/memento-note/lib/ai/services/agent-executor.service.ts index 04df9f4..2e45063 100644 --- a/memento-note/lib/ai/services/agent-executor.service.ts +++ b/memento-note/lib/ai/services/agent-executor.service.ts @@ -901,6 +901,24 @@ async function executeToolUseAgent( const duration = Date.now() - startTime + // Détecte si le modèle ne supporte pas le function calling + // (il retourne le JSON de l'outil comme texte brut au lieu de l'exécuter) + const totalToolCallsCheck = result.steps.reduce((acc, s) => acc + s.toolCalls.length, 0) + if (totalToolCallsCheck === 0 && result.text) { + const trimmed = result.text.trim() + if (trimmed.startsWith('[{"type":"function"') || trimmed.startsWith('[{\n "type": "function"')) { + await prisma.agentAction.update({ + where: { id: actionId }, + data: { + status: 'error', + error: `Le modèle "${sysConfig.AI_MODEL_CHAT}" ne supporte pas le function calling (tool use). Utilisez un modèle compatible dans les paramètres admin, par exemple : openai/gpt-4o-mini, google/gemini-flash-1.5, anthropic/claude-3-haiku, ou mistralai/mistral-small.`, + completedAt: new Date(), + } + }) + return { success: false, actionId, error: 'Model does not support tool calling' } + } + } + // Build tool log trace const toolLog = result.steps.map((step, i) => ({ step: i + 1,