π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(sandbox): stop sending every conversation to a directory that isn't there (#20486)
Rdmclin2c1f825fb3f60
diff --git a/packages/builtin-tool-cloud-sandbox/src/systemRole.ts b/packages/builtin-tool-cloud-sandbox/src/systemRole.tsindex 0034d753e9e..0f1b0e8205b 100644--- a/packages/builtin-tool-cloud-sandbox/src/systemRole.ts+++ b/packages/builtin-tool-cloud-sandbox/src/systemRole.ts@@ -1,5 +1,3 @@-import { SANDBOX_UPLOADED_FILES_DIR } from './uploadedFiles';-export const systemPrompt = `You have access to a Cloud Sandbox that provides a secure, isolated environment for executing code and file operations. This sandbox runs on AWS Bedrock AgentCore and is completely separate from the user's local system.@@ -15,10 +13,7 @@ export const systemPrompt = `You have access to a Cloud Sandbox that provides a</sandbox_environment>-<uploaded_files>-Files the user uploaded in this conversation (attachments and session files) are automatically synced into \`${SANDBOX_UPLOADED_FILES_DIR}\` when your sandbox session starts. If the user refers to a file they shared, look there first β do NOT ask them to re-upload. Run \`listFiles\` on \`${SANDBOX_UPLOADED_FILES_DIR}\` to see everything that is available.{{sandbox_uploaded_files}}-</uploaded_files><preinstalled_software>diff --git a/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.test.ts b/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.test.tsnew file mode 100644index 00000000000..98bca3ed6aa--- /dev/null+++ b/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.test.ts@@ -0,0 +1,35 @@+import { describe, expect, it } from 'vitest';++import { systemPrompt } from './systemRole';+import { formatUploadedFilesPrompt, SANDBOX_UPLOADED_FILES_DIR } from './uploadedFiles';++describe('formatUploadedFilesPrompt', () => {+ it('says nothing at all when the conversation has no attachments', () => {+ // The section used to be static, so every conversation was told to run+ // `listFiles` on a directory that is only created while syncing files β+ // the agent spent a call on `Directory not found` and then had to reason+ // its way out of a failure that was never real.+ expect(formatUploadedFilesPrompt([])).toBe('');+ expect(formatUploadedFilesPrompt([{ name: '' }])).toBe('');+ });++ it('carries the directory instruction with the files it describes', () => {+ const rendered = formatUploadedFilesPrompt([{ name: 'report.csv', size: 2048 }]);++ expect(rendered).toContain('<uploaded_files>');+ expect(rendered).toContain(SANDBOX_UPLOADED_FILES_DIR);+ expect(rendered).toContain(`${SANDBOX_UPLOADED_FILES_DIR}/report.csv`);+ expect(rendered).toContain('</uploaded_files>');+ });+});++describe('systemPrompt', () => {+ it('names the upload directory only through the placeholder', () => {+ // The static prompt must not mention it: everything the agent is told+ // about that directory has to arrive with the files, or a conversation+ // without any is pointed at a path that does not exist.+ expect(systemPrompt).toContain('{{sandbox_uploaded_files}}');+ expect(systemPrompt).not.toContain(SANDBOX_UPLOADED_FILES_DIR);+ expect(systemPrompt).not.toContain('<uploaded_files>');+ });+});diff --git a/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.ts b/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.tsindex af4fd1c0259..5d0921a4419 100644--- a/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.ts+++ b/packages/builtin-tool-cloud-sandbox/src/uploadedFiles.ts@@ -62,9 +62,14 @@ export const sandboxUploadedFilePath = (name: string): string =>`${SANDBOX_UPLOADED_FILES_DIR}/${sanitizeSandboxFileName(name)}`;/**- * Render the dynamic `{{sandbox_uploaded_files}}` section listing the files that- * are pre-loaded into the sandbox. Returns an empty string when there are no- * files so the surrounding system prompt renders cleanly.+ * Render the whole `<uploaded_files>` section, or nothing at all.+ *+ * The section used to be static in the prompt with only the file list filled+ * in, so a conversation with no attachments still read "run `listFiles` on+ * /mnt/data" β and that directory is only created while syncing files, so the+ * agent spent a tool call on `Directory not found` and then had to reason its+ * way out of a failure that was never real. Nothing is uploaded in most+ * conversations, so the instruction belongs with the files it describes.** Applies the same size/count caps as the bootstrap and de-dupes by resolved* sandbox path, so the listed files match exactly what is written to disk.@@ -85,5 +90,11 @@ export const formatUploadedFilesPrompt = (files: SandboxUploadedFileMeta[]): strif (lines.length === 0) return '';- return ['These user-uploaded files are pre-loaded and ready to use:', ...lines].join('\n');+ return [+ '<uploaded_files>',+ `Files the user uploaded in this conversation (attachments and session files) are automatically synced into \`${SANDBOX_UPLOADED_FILES_DIR}\` when your sandbox session starts. If the user refers to a file they shared, look there first β do NOT ask them to re-upload. Run \`listFiles\` on \`${SANDBOX_UPLOADED_FILES_DIR}\` to see everything that is available.`,+ 'These user-uploaded files are pre-loaded and ready to use:',+ ...lines,+ '</uploaded_files>',+ ].join('\n');};