Bug:非扩权(non-widening)的 sandbox_permissions 请求未降级处理,而是直接抛出异常——导致在 workspace-write 和 danger-full-access 会话中,所有工具调用均失败。
#4976
Replies: 2 comments
|
Interesting — and the root cause is a bit sharper than "approveEscalation throws wrong." I dug into the alpha.1 source and want to add the schema/execution mismatch angle, plus one spec-test wrinkle your suggested fix will hit. 1. The schema advertises the full vocabulary regardless of the session's effective mode — that's what invites the invalid request.
const escalationModes: readonly SandboxMode[] = defaultMode === undefined ? [] : ESCALATION_TARGETSSo as soon as a composition has a default mode (workspace-write or danger-full-access), it advertises all of The result is exactly the double-bind you describe: a 2. Your one-line fix would change tested, deliberate behavior — watch
it('a non-widening request fails closed with its own text and never asks', async () => {
await expect(approveEscalation(req({ requestedMode: 'read-only' }), spy))
.rejects.toThrow(/not strictly wider than this call's current "read-only" mode/)
await expect(approveEscalation(req({ requestedMode: 'workspace-write', effectiveMode: 'danger-full-access' as never }), spy))
.rejects.toThrow(/not strictly wider/)
expect(seen).toEqual([])
})Two things stand out:
3. The cleanest resolution is the per-session enum filter, not the equal-mode special-case. If the schema only advertises the modes strictly wider than the session's effective mode, then:
This removes the invitation to misbehave rather than forgiving the misbehavior after the fact, and it doesn't require weakening the fail-closed contract in Same for the Verified at Happy to help test a candidate fix or run the spec against a |
安装 / 环境(「Bug:非扩权(non-widening)的
|
Uh oh!
There was an error while loading. Please reload this page.
Environment
@deepseek-ai/dsh 0.1.1-rc.2(installed globally via npm, Windows)dsh webworkspace-write(session default); also reproduced withdanger-full-accessSymptoms
The model attaches
sandbox_permissions: "workspace-write"(sometimes with an emptyjustification) to every tool call — pwsh, bash, fs edits — even though the session's effective mode is alreadyworkspace-write. Every call then fails with:Making things worse:
danger-full-accessevery escalation request throws, becauseWIDER_MODEShas no key for it, soWIDER_MODES[effectiveMode] ?? []is always an empty array → fail-closed. In this mode the error is 100% reproducible and nothing can execute at all.Error: invalid justification: expected a non-empty sentence.Net effect: the agent cannot run commands or write files at all. From the user's perspective this looks like a runtime sandbox fault, not a project issue.
Root cause
In
packages/sandbox/sandbox/src/escalation.ts:ESCALATION_TARGETS = ['workspace-write', 'danger-full-access']) whenever a confining executor is mounted — independent of the call's effective mode. The doc comment itself says "schemas are registry-global while the effective mode is per-call truth."sandbox_permissionsas a same-turn retry after a denial. In practice models do not follow this discipline reliably and set it speculatively on ordinary calls.approveEscalationthen throws on any request that is not strictly wider:So a request that is equal to or narrower than the current mode — i.e. a call that needs no escalation at all — is turned into a hard error instead of being resolved as a no-op. This contradicts the function's own documented stance: "A non-widening request never prompts a human" (it doesn't prompt — it throws at everything).
Suggested fix
Treat a non-widening request as a no-op: grant the call the current effective mode instead of throwing. Genuine strictly-wider escalations keep the existing approval choreography untouched:
This is safe: the granted mode is exactly what the call would have run under had the model simply omitted
sandbox_permissions— no privilege is widened, and the approval channel is only engaged for real widenings (verified:read-only → workspace-writeandworkspace-write → danger-full-accessstill route throughapprover.request).Local workaround (verified)
Patching
approveEscalationas above innode_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js(0.1.1-rc.2) fixes all four branches:workspace-writeworkspace-writedanger-full-accessworkspace-writeread-onlyworkspace-writeworkspace-writedanger-full-accessChecked against
v0.1.2-alpha.1source:escalation.tsis unchanged there, so the issue presumably still applies.Secondary suggestion: consider filtering the schema enum per-session (only advertise targets strictly wider than the session's effective mode), which would stop models from forming invalid escalation requests in the first place.
Happy to provide more details or test a candidate fix. Thanks for the great project!

(以上内容由GLM-5.3 Flash自动生成)
All reactions