Repository navigation
Description
Description
In a @ai-sdk/sandbox-just-bash session, changing a file through a symlinked directory doesn't work, while reading through the same link does:
writeTextFileandwriteBinaryFileresolve without an error, but the file can't be read back, through the link or in the real directory.deleteFilethrowsENOENT: no such file or directory, rm '/work/link/old.txt', althoughstaton the same path finds the file.- A shell command such as
echo hi > /work/link/a.txtexits 0 and writes nothing.
An agent that keeps its workspace behind a symlink, or creates one with ln -s, loses its writes without any error.
The cause is in just-bash's InMemoryFs: its write methods don't resolve symlinks in the parent path, while its read methods do. It's the same in just-bash 2.14.5, which this package depends on, and in the latest 3.6.1. I've opened a fix there: vercel-labs/just-bash#782.
Expected: writes, deletes and shell commands go to /work/real, as they do on a real filesystem.
Reproduction
// repro.mjs, after `npm install @ai-sdk/sandbox-just-bash@1.0.196`
import { createJustBashNetworkSandboxSession } from '@ai-sdk/sandbox-just-bash';
const session = (await createJustBashNetworkSandboxSession()).restricted();
await session.run({ command: 'mkdir -p /work/real && ln -s /work/real /work/link' });
await session.writeTextFile({ path: '/work/link/notes.md', content: 'hello' });
console.log('read back via link:', await session.readTextFile({ path: '/work/link/notes.md' }));
console.log('in the real dir: ', await session.readTextFile({ path: '/work/real/notes.md' }));
await session.writeTextFile({ path: '/work/real/old.txt', content: 'x' });
try {
console.log('deleteFile via link:', await session.deleteFile({ path: '/work/link/old.txt' }));
} catch (error) {
console.log('deleteFile via link threw:', error.message);
}
const shell = await session.run({ command: 'echo hi > /work/link/a.txt; echo "exit $?"; ls /work/real' });
console.log('shell write via link:', JSON.stringify(shell.stdout));node repro.mjs prints:
read back via link: null
in the real dir: null
deleteFile via link threw: ENOENT: no such file or directory, rm '/work/link/old.txt'
shell write via link: "exit 0\nold.txt\n"
With the just-bash fix built from its main branch (3.6.1) and swapped in for the installed just-bash 2.14.5, the same script prints the expected output. Picking up the fix here means moving to a just-bash release that has it, since this package depends on ^2.14.5.
read back via link: hello
in the real dir: hello
deleteFile via link: true
shell write via link: "exit 0\na.txt\nnotes.md\n"
AI SDK Version
- @ai-sdk/sandbox-just-bash: 1.0.196 (just-bash 2.14.5)
- ai: 7.0.184
- Node 26.13.0, macOS
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
ai-sdk-factory commentedon Nov 28, 2026
Identify issue type
Identified as Bug
Confidence: High
Rationale
The issue reports concrete filesystem failures in current sandbox behavior: silently lost writes and unexpected deletion errors. The proposed dependency update addresses those failures rather than adding a new capability.
Evidence
ai-sdk-factory commentedon Nov 28, 2026
Bug discovery clarification
@FredAmartey, how did you discover this bug? Did you encounter it while using the AI SDK in production, find it while auditing or reviewing AI SDK source code, or discover it another way? Please describe the original discovery context.
The report demonstrates the bug and diagnoses an upstream cause, but does not establish whether it was originally discovered in production or through source auditing. Ask the original author how they discovered it.
FredAmartey commentedon Nov 29, 2026
Ran into this while using
@ai-sdk/sandbox-just-bashin our staging env for a sandboxed agent workflow where a workspace path went through a symlinked directory.Reading files through the symlinked path worked normally, so it wasn't immediately obvious anything was wrong until we noticed writes were resolving/exiting
0without persisting anddeleteFilewas throwingENOENTon filesstatcould still see. From there I isolated the minimal reproduction above, traced the cause tojust-bash'sInMemoryFs, and openedvercel-labs/just-bash#782.ai-sdk-factory commentedon Nov 29, 2026
Identify bug discovery
Discovery source:
discovery:other(high confidence).The author explicitly discovered the bug in a staging environment, not production or a source audit. Source inspection occurred afterward to diagnose the failure.
FredAmartey commentedon Nov 29, 2026
It is also present in our production environment
ai-sdk-factory commentedon Nov 30, 2026
Bug Reproduction - AI SDK 7
Bug is outside the AI SDK codebase scope.
Target branch:
main@ai-sdk/sandbox-just-bash1.0.197 with lockedjust-bash2.14.5 under Node 22.23.4./work/linksucceed, but text and binary writes resolve without producing readable files through either path./work/link/old.txtthrows ENOENT and leaves the target intact; shell redirection exits 0 without persisting its output.examples/ai-functions/src/reproduction/issue-25591.tsexercises every reported operation and fails because writes should persist in/work/realand deletion should remove the target.packages/sandbox-just-bash/src/just-bash-sandbox-session.tsforwards writes tofs.writeFile, deletion tofs.rm, and commands to native execution, locating the defect in external just-bash rather than SDK request shaping.Relevant Documentation