ksndjaks/dsh-image-budget-guard

Trims the oldest request images before a model request is assembled, so inline base64 bodies stop growing into slow, flaky or rejected calls.

Third-party gateways have no Files API, so every retained image is re-encoded and re-uploaded with every request — first-token latency climbs, connections fail more often, and 503s appear, while the official route stays flat on the same model. This trims the oldest images on the session surface before the request is assembled, which keeps the body under the budget instead of discovering it by rejection. Sizes come from the request-image projection rather than a separate estimate, the decision is recorded as a log entry rather than hidden clipping state, and only the oldest end is trimmed so the prefix cache stays intact up to that point. Estimation errors, a missing projection or a stale log never fail a turn — the guard degrades to leaving the request alone.

Usage & Billing ★ 2
View on GitHub ↗

Install

dsh plugin --profile web add github:ksndjaks/dsh-image-budget-guard

The README lists the npm form but marks it explicitly as not available yet, so the GitHub install is the working path — it also works by pasting the repository URL into the DSH plugin panel. It says the desktop app has not been tested yet, and asks you to restart the profile afterwards.

Compatibility

Hooks the agent/request waterfall and measures with the same request-image projection the request is built from. Retention floors are configurable: the newest minRetainImages occurrences and every image inside a protected window are kept. Inline base64 routes use a byte budget, and the author documents the two transports separately — the official route uploads each image once to /v1/files with byte and count budgets (128 MiB, 600 images) and 7-day file-id expiry, while a third-party gateway inlines base64 with per-image 4 MP and 1 MiB caps plus a 20 MiB per-request cap.

Details

Alternatives

devacc8/dsh-billing-badge · dshworks/dsh-meter · satan9394/dsh-usage-unified

More plugins in Usage & Billing

Browse more in Usage & Billing

Guides for Usage & Billing plugins