qq744287383/dsh-image-size-guard ↗★ 0

dsh-image-size-guard

Keeps model requests under each provider's request-body ceiling by replacing the oldest history images with placeholder text.

套件
dsh-image-size-guard
相容性
待驗證
版本
1.2.0
授權
MIT
最近更新
2026年11月2日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add dsh-image-size-guard

Usage

Open Settings → Image size guard. The page lists one row per guarded provider and supports add, edit, remove, and enable/disable.

FieldMeaning
ProviderThe provider route name, such as agent2api.
Request limit (MiB)The largest request body that provider accepts. Decimals are allowed (10.5).
Reserve (KiB)Headroom kept free below the limit.
Placeholder size (bytes)Bytes one omitted image is estimated to occupy.
EnabledWhether the guard acts on this provider.

Each row carries a switch on the right. Flipping it saves the row with only enabled changed, so the limit never has to be retyped, and a disabled row stops guarding immediately — its requests pass through untouched. The row also dims, so a switched-off provider reads as off at a glance. The switch is a real role="switch" button, so it answers to Enter and Space and reports its state to screen readers.

Each size is edited in the unit its field names, so a value never has to be converted by hand: the default row reads 16 / 256 / 512. The stored values stay exact bytes; the panel converts on open and on save.

The page also offers the providers the LLM registry advertises that no row covers yet, so a new provider is one click away instead of a typed guess.

Saving writes the profile patch layer through configEditor.edit, which validates with this plugin's own Config and reconciles the Loader. The guard and the panel therefore read one source of truth, and a save takes effect without restarting the Harness. Removing the last row is allowed: it means no provider is guarded.

The panel talks to POST /image-size-guard/limits. The Host admits each request through connection.admit, so it carries the same Host/Origin checks and browser session as the rest of the API.

Configuration

The panel edits this row; the YAML below is the same value in file form.

- insert:
    - id: image-size-guard
      name: 'dsh-image-size-guard'
      config:
        providers:
          - provider: agent2api
            maxRequestBytes: 16777216
            reserveBytes: 262144
            placeholderBytes: 512
            targetTurns: 5
            minFillPercent: 40
            protectedTurns: 2
            growthWindow: 8
            enabled: true
KeyDefaultMeaning
providersone agent2api rowProvider limit rows. Omit the field for that default; an explicit empty list guards nothing.
providers[].provider—Provider route name.
providers[].maxRequestBytes16777216 (16 MiB)The gateway's request-body ceiling.
providers[].reserveBytes262144 (256 KiB)Headroom kept free below the ceiling.
providers[].placeholderBytes512Bytes assumed for one placeholder block.
providers[].targetTurns5Turns of growth one batch should buy below the ceiling. 0 disables batching and restores the minimal policy.
providers[].minFillPercent40Lowest share of the budget, in percent, a batch may leave behind.
providers[].protectedTurns2Newest turns whose images a batch leaves alone. 0 protects nothing.
providers[].growthWindow8Turns sampled to estimate per-turn growth.
providers[].enabledtrueWhether the guard acts on this provider.

The budget a request is measured against is maxRequestBytes - reserveBytes. The reserve exists because the estimate models the JSON body, not the provider envelope or HTTP headers, which are invisible at this seam.