deepseek-ai/deepseek-harness · error

permission switch failed: ${result.error.code}: ${result.err

Error message

permission switch failed: ${result.error.code}: ${result.error.message}

What it means

The /permission decoration's onSelect switches presets by running the literal line '/permission <option.id>' through the live session's command API. A non-ok RPC result throws 'permission switch failed: <code>: <message>'; a delivered but unmatched line is reported separately (error 197). The 'not materialized yet' sibling check guards the session lookup before this call.

Source

Thrown at packages/client/ui-permission-presets/src/client/index.ts:153

  ctx.effect(() => command.decorate({
    name: 'permission',
    // The picker exists exactly while the projection does: a permission-less
    // host serves no key and the bare invocation falls through to the host
    // command (which is absent too — the line simply misses).
    available: session => selectOf(sessionFor(session)) !== undefined,
    ui: {
      kind: 'popupSelect',
      options: (session) => {
        const value = selectOf(sessionFor(session))
        if (value === undefined) throw new Error('permission presets are not available on this host')
        return Promise.resolve(optionsOf(value, t))
      },
      onSelect: async (option, session) => {
        const live = sessionFor(session)
        if (live === undefined) throw new Error('this session is not materialized yet')
        const result = await live.command(`/permission ${option.id}`)
        if (!result.ok) throw new Error(`permission switch failed: ${result.error.code}: ${result.error.message}`)
        if (!result.value.matched) throw new Error('the host offers no /permission command')
      },
    },
  }), 'ui-permission: /permission decoration')
}

View on GitHub (pinned to b150a551b8)

Solutions

  1. Inspect the embedded code/message for the host-side reason
  2. Reconnect and select the preset again
  3. Confirm sessionFor(session) returned a live session before offering the control
Defensive patterns

Strategy: try-catch

Validate before calling

if (sessionFor(session) === undefined) return // not materialized yet

Try / catch

try {
  await applyPreset(option.id)
} catch (error) {
  surfacePermissionError(error) // keep the current selection visible
}

Prevention

When it happens

Trigger: Selecting a permission preset while the command RPC fails: the session dropped, the host command handler errored, or the transport reset mid-call.

Common situations: A connection blip while the user picks a preset; the host restarting; an authorization failure for the command execution.

Related errors


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/4e7f0e46d9ae2d3e. Report an issue: GitHub.