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

Đã đóng
#2,034 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@tombeckenham đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #2039 của @pcbeingused333 — đã merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
378
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
254

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/ai

Tất cả issue của TanStack/ai

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.