diff --git a/backend/windmill-api/src/ai_session_tools/storage.rs b/backend/windmill-api/src/ai_session_tools/storage.rs index 1baa62cab2..7e9c1cdfea 100644 --- a/backend/windmill-api/src/ai_session_tools/storage.rs +++ b/backend/windmill-api/src/ai_session_tools/storage.rs @@ -261,7 +261,19 @@ async fn read_s3_file(ctx: &Ctx<'_>, args: &Value) -> ToolResult { fit_text(&mut out, content, length < size, csv_cut); } None => { - out.insert("preview_unavailable".into(), preview["msg"].clone()); + // The endpoint's "Preview is not available" reads to a model as if the user + // could not see the file either, even while it is open in the side panel. + let reason = match preview["msg"].as_str() { + Some(m) if m.starts_with("Preview is not available") => { + "it is not a text, table or image file" + } + Some(m) => m, + None => "the server returned no content", + }; + out.insert( + "content".into(), + format!("Not read by this tool: {reason}.").into(), + ); } } // The text preview reads no .jsonl or .ndjson, which query_s3_table does. diff --git a/frontend/src/lib/components/copilot/chat/storageTools.ts b/frontend/src/lib/components/copilot/chat/storageTools.ts index 63718af634..3384e4fd30 100644 --- a/frontend/src/lib/components/copilot/chat/storageTools.ts +++ b/frontend/src/lib/components/copilot/chat/storageTools.ts @@ -184,7 +184,9 @@ export function getStorageTools(): SessionTool<{}>[] { const openS3File = (helpers as GlobalToolHelpers | undefined)?.openS3File if (parsed.open_in_preview) { if (openS3File) openS3File(file) - result.side_panel = openS3File ? 'opened' : 'this chat has no side panel' + result.side_panel = openS3File + ? 'opened: the user now sees the file next to the chat' + : 'this chat has no side panel' } toolCallbacks.setToolStatus(toolId, { content: `Read ${s3}${storageLabel(storage)}`,