{"record":{"id":"968764d16221310c","repo":"vercel/ai","slug":"sandbox-session-is-not-available-968764","errorCode":null,"errorMessage":"Sandbox session is not available","messagePattern":"Sandbox session is not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/anthropic/src/tool/bash_20250124.ts","lineNumber":87,"sourceCode":"export function bash_20250124<OUTPUT>(\n  options: Omit<Bash20250124Options<OUTPUT>, 'execute'> & {\n    execute: Bash20250124Options<OUTPUT>['execute'];\n  },\n): ProviderDefinedTool<Bash20250124Input, OUTPUT, {}>;\nexport function bash_20250124<OUTPUT>(\n  options: Bash20250124OptionsWithNullableExecute<OUTPUT> = {},\n): ProviderDefinedTool<Bash20250124Input, OUTPUT, {}> {\n  const { execute, ...rest } = options;\n\n  if (execute === undefined) {\n    return bash_20250124_internal({\n      ...rest,\n      execute: async (\n        { command },\n        { abortSignal, experimental_sandbox: sandbox },\n      ) => {\n        if (!sandbox) {\n          throw new Error('Sandbox session is not available');\n        }\n\n        return await sandbox.run({\n          command,\n          abortSignal,\n        });\n      },\n    } as Bash20250124Options<Bash20250124DefaultOutput>) as ReturnType<\n      typeof bash_20250124_internal<OUTPUT>\n    >;\n  }\n\n  return bash_20250124_internal({\n    ...rest,\n    ...(execute === null ? {} : { execute }),\n  } as Bash20250124Options<OUTPUT>);\n}\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/anthropic/src/tool/bash_20250124.ts#L69-L105","documentation":"Identical to the bash_20241022 variant: the bash_20250124 tool's execute callback throws 'Sandbox session is not available' when no `experimental_sandbox` session is present in the tool-call options. Commands can only be executed through a sandbox.","triggerScenarios":"Using the anthropic bash_20250124 tool (via bashTool) in generateText/streamText where the call options lack experimental_sandbox.","commonSituations":"Migrating to the newer 20250124 bash tool version without also wiring sandbox configuration; running agents in environments with no sandbox provider installed.","solutions":["Pass an `experimental_sandbox` session (e.g. from @ai-sdk/sandbox or a custom implementation) in the tool execution options.","Remove the bash tool if your runtime cannot supply a sandbox, replacing it with a controlled custom tool.","Ensure the sandbox session is created before the agent loop executes tool calls."],"exampleFix":"// before\nsteps: tools: { bash: bash_20250124({ ... }) } // executed without sandbox\n// after\nconst sandbox = await createSandbox();\nawait generateText({\n  tools: { bash: bash_20250124({ ... }) },\n  experimental_context: { experimental_sandbox: sandbox },\n});","handlingStrategy":"validation","validationCode":"if (!sandboxSession) {\n  throw new Error('bash_20250124 tool requires an experimental_sandbox session');\n}\n// configure the sandbox before starting generateText/streamText","typeGuard":"function hasSandbox(opts: any): opts is { experimental_sandbox: { run: (args: { command: string }) => Promise<unknown> } } {\n  return !!opts?.experimental_sandbox && typeof opts.experimental_sandbox.run === 'function';\n}","tryCatchPattern":"try {\n  return await sandbox.run({ command, abortSignal });\n} catch (error) {\n  if (error instanceof Error && error.message === 'Sandbox session is not available') {\n    return { type: 'error', error: 'Initialize an experimental_sandbox session to use the bash_20250124 tool.' };\n  }\n  throw error;\n}","preventionTips":["Wire sandbox creation into agent setup whenever bash tool versions are enabled.","Fail fast with a startup config check rather than at first tool call.","Keep sandbox setup shared between old and new bash tool versions to avoid migration gaps."],"tags":["tooling","sandbox","missing-dependency"],"backgroundTag":"missing-sandbox-session","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}