withSandbox fails with "never called provide()" when the sandbox has no workspace

Cerrado
#2,034 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@tombeckenham ya está trabajando en esto.

Desde el 4/11/2026.

  • #2039 de @pcbeingused333 — fusionado

Evaluación

Este issue todavía no se ha evaluado.

Descripción

has-pr waiting-on: maintainer
TanStack AI version

@tanstack/ai 1.1.0, @tanstack/ai-sandbox 1.1.0, @tanstack/ai-sandbox-local-process 1.0.0

Framework/Library version

Node.js 26.13.0 and 24.22.2. No UI framework.

Describe the bug and the steps to reproduce it

workspace is optional on SandboxConfig, but a sandbox without one fails at the first chat():

Middleware "sandbox" declares it provides "sandbox-projection" but never called provide() in setup().

Expected: the run works and projects nothing. Or, if a workspace is necessary, the type makes workspace required.

Steps. Run pnpm install && pnpm start. It needs no API key, because the model is fakeText from @tanstack/ai/testing.

const sandbox = defineSandbox({
  id: 'no-workspace',
  provider: localProcessSandbox(),
  // no `workspace`
})

chat({
  adapter, // fakeText() with one scripted answer
  threadId: 'thread-1',
  messages: [{ role: 'user', content: 'hi' }],
  middleware: [withSandbox(sandbox)],
})

Output, the same in 3 of 3 runs:

FAILED: Middleware "sandbox" declares it provides "sandbox-projection" but never called provide() in setup().

We hit this with a sandbox that resumes an existing provider sandbox, which already holds its files. A workaround is workspace: defineWorkspace({ source: { type: 'none' } }). With that, the same script finishes.

Suspected cause (not confirmed). withSandbox lists ProjectionCapability in provides (middleware.ts), but it calls provideWorkspaceProjection only inside if (workspace !== undefined).

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://github.com/adelrodriguez/tanstack-ai-repros/tree/main/withsandbox-without-workspace

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Lenguaje dominante
TypeScript
Estrellas
3.3k
Forks
378
Merge medio
1 d 2 h
PR fusionados (30 d)
254

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/ai

Todos los issues de TanStack/ai

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.