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

Chiusa
#2,034 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@tombeckenham ci sta già lavorando.

Dal 4/11/2026.

  • #2039 di @pcbeingused333 — integrata

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.
Lingua principale
TypeScript
Stelle
3.3k
Fork
378
Merge medio
1g 2h
PR unite (30g)
254

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/ai

Tutte le issue di TanStack/ai

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.