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

已关闭
#2,034 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@tombeckenham 已经在做这个了。

开始于 2026年11月4日。

  • #2039 来自 @pcbeingused333 —— 已合并

评估

这个 Issue 还没有评估数据。

描述

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.
主要语言
TypeScript
星标
3.3k
派生
378
平均合并
1 天 2 小时
30 天内合并 PR
254

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/ai 的其他 Issue

查看 TanStack/ai 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。