DSH uses a plugin-based architecture. In real-world development, it often needs to manage multiple credential groups under one logical Provider identity. dsh-multiprovider is a plugin designed for this purpose. It takes over account selection, session affinity, health status, and cooldown policies, without involving specific model-routing logic.

This plugin is maintained by monotykamary and follows the MIT license. It provides provider-neutral multi-account scheduling, session affinity, health monitoring, and a settings interface for DeepSeek Harness.

Core features

The plugin mainly provides the following capabilities:

  • Deterministic scheduling: Supports round-robin, weighted, least-in-flight, and priority strategies.
  • Session affinity: Keeps related requests on the same account through affinityKey.
  • Visible health status: Shows cooldown time, failure classification, and the number of in-flight requests.
  • Credential management: Uses Provider-held opaque references (does not store keys directly).
  • Real-time preferences: Enable, adjust weights, or change priorities directly from the DSH settings interface.
  • Normalized failure health: Recognizes error types such as rate-limit, auth, transient, and fatal.
  • Configurable cooldowns: Supports exponential backoff strategies.
  • Settings interface: Provides a dedicated Accounts section in the DSH settings modal.

Installation and activation

Before using it, ensure the environment meets the following requirements: Node.js ^22.19.0 || >=24, pnpm 11, and DeepSeek Harness ^0.1.1.

Run the following command to install it:

pnpm dlx @monotykamary/dsh@latest plugin --profile web add dsh-multiprovider

After installation, the plugin is injected as a Cordis service into ctx.multiprovider.

Typical usage

1. Register Provider Inventory

Inject the multiprovider service in a Provider plugin and define the account list and failure-classification logic.

import type { Context } from '@monotykamary/cordis'
import type {} from 'dsh-multiprovider'

export function installAccounts(ctx: Context) {
  ctx.inject(['multiprovider'], (mctx) => {
    mctx.effect(() => mctx.multiprovider.registerProvider({
      id: 'anthropic',
      label: 'Anthropic',
      managementHint: 'Add and remove keys in the Anthropic provider settings.',
      accounts: async () => [
        {
          id: 'work',
          label: 'Work key',
          authKind: 'api-key',
          credentialRef: { kind: 'record', key: 'anthropic/work' },
          weight: 3,
          metadata: { organization: 'Work' },
        },
        {
          id: 'personal',
          label: 'Personal key',
          authKind: 'api-key',
          credentialRef: { kind: 'record', key: 'anthropic/personal' },
        },
      ],
      classifyFailure: (error) => {
        const status = (error as { status?: number }).status
        if (status === 429) return { kind: 'rate-limit', retryable: true }
        if (status === 401 || status === 403) return { kind: 'auth', retryable: true }
        if (status !== undefined && status >= 500) return { kind: 'transient', retryable: true }
        return { kind: 'fatal', retryable: false }
      },
    }), 'anthropic: multiprovider accounts')
  })
}

2. Acquire and Release Leases

In business logic, acquire an account through acquire, and always call release after the operation completes.

const attempted = new Set<string>()

for (;;) {
  const lease = await ctx.multiprovider.acquire({
    providerId: 'anthropic',
    affinityKey: session.id,
    excludeAccountIds: attempted,
  })
  attempted.add(lease.accountId)

  try {
    const credential = await resolveCredential(lease.credentialRef)
    const result = await runCompleteProviderOperation(credential)
    lease.release({ status: 'success' })
    return result
  } catch (error) {
    const disposition = lease.release({ status: 'failure', error })
    if (!disposition?.retryable || !isSafeToReplay(error)) throw error
    // Reacquiring with excludeAccountIds selects another eligible account.
  }
}

Notes

  • Credential security: Credentials exist as opaque references and do not enter browser snapshots.
  • Streaming requests: For streaming LLM requests, you must hold the lease until the stream completes or fails, not merely create an iterator.
  • Settings security: The settings interface allows only same-origin access to protect credentials.
  • Lease release: You must explicitly call lease.release(); otherwise, the account cannot be used by other requests.

Summary

dsh-multiprovider reduces the complexity of multi-account scheduling by standardizing account management and health-checking mechanisms. Its codebase is available on GitHub, and you can view the details on the SkillHub catalog page.