dsh-image-once: Inlining Conversational Images Only in the First Request

Preface

In DeepSeek Harness (DSH), after pasting screenshots or using the image reading tool, the default pipeline re-inlines every image in the conversation that has not been offloaded as base64 into every request sent to the model. As conversations lengthen and the number of images grows, the request body size amplifies linearly, significantly slowing down the Time To First Byte (TTFT). Real-world tests in the README show that while a plain text request (approx. 49B) takes about 2.5s for the first byte, a 4MB-level body can exceed 20s. Furthermore, the bottleneck is often gateway-side ingest rather than local upload bandwidth.

If your primary workflow involves “pasting an image for a quick look, then continuing the discussion via text,” a more rational approach is: inline each image only when it first appears in a request, and subsequently use Harness’s built-in placeholder text (including the local read-only path). The model can then call read_image if it needs details, inlining it again at that time. The following describes how the community plugin dsh-image-once (Maintainer: senyayume, Category: Workflow) implements this strategy.

What is this

dsh-image-once is a workflow plugin for DSH. It tracks every “image occurrence” based on sessionId + message.id + content tree path + attachmentId. It inlines the image as-is the first time it is seen, recording it as “sent” only after the request produces its first chunk (failures or retries do not count). On subsequent requests, any occurrence is marked offloaded: true, and DSH’s existing logic replaces it with placeholder text containing the local read-only path. Auxiliary requests with a purpose (such as conversation titles or summaries) are neither modified nor tracked. Tracking occurs only in memory and affects only the copy of the current request; it is not written back to the session.

SkillHub is a community plugin directory and has no official affiliation with DeepSeek or High-Flyer. Please review the source code and license before installation. The plugin runs under the permissions of the current DSH process.

Core Features

Request Body and TTFT

The plugin targets the behavior in paths like dsh-llm-pi-ai where “the entire image base64 is resent with every step request.” When enabled, the same image will not repeatedly bloat the request body in subsequent steps, helping to reduce waiting times in scenarios with large bodies.

Occurrence and Re-viewing

An “occurrence” is defined by the session, message ID, path in the content tree, and attachmentId. When the model re-views an image via read_image, it counts as a new occurrence and will be inlined again in the corresponding request.

Two Message Shapes

The structure of read_image results varies across DSH versions. The plugin performs a recursive scan for both shapes (consistent with the Harness contentHasImage criteria) to avoid silent failures:

Shape Typical Source Structural Highlights
Flat Built-in DSH createToolResultMessage { role: "tool", content: [text, image] }
Nested Message construction in @deepseek-ai/dsh-llm-pi-ai within profiles content nested within tool-result

Rewriting adopts a block-by-block reconstruction approach: unchanged text blocks, tool-result shells, etc., are preserved as-is.

Provider and Model Scope

In Settings → Plugins, locate dsh-image-once. The switch on the right side of the row controls whether the entire plugin is active; click “Configure” to enter the provider list. Each row has a switch: if off, that provider bypasses this plugin entirely. The “Limit Models” option on the right allows narrowing the scope to specific model IDs for that provider. The list is derived from the host registry; the plugin does not hardcode provider names. By default, it applies to all providers and all models; changes take effect immediately without a restart.

Installation and Activation

Local package form (dsh.bundle.patch + cordis.patch.yml). The installation command follows the “Assembly” section of the README:

dsh plugin --profile <profile> add <package directory|github:senyayume/dsh-image-once>

After installation, it enters dsh.profile.bundles, where it becomes visible and toggleable in the plugin page. package.json requires Node >=20 and retains @deepseek-ai/schemastery as a peerDependency (the host half-body depends on this package).

If you modify lib/index.js, lib/client.js, cordis.patch.yml, or package.json, you need to restart the entire DSH Desktop package: the host replays patches via hot reload but reuses the Node ESM module cache, so .js changes may not be picked up via hot update; client-related changes also require a client-modules rescan.

Configuration (Optional)

The UI and YAML point to the same stored config; maintain only one location.

Edit in Settings → Plugins → dsh-image-once → Configure, which is equivalent to writing into the profile patch (semantic example below):

- id: image-once
  config:
    providers:
      <adapter_registration_name>:
        enabled: false                            # This provider completely bypasses this plugin
        models: [deepseek/deepseek-v4.1-flash]    # Only effective for these models; empty array = all models for this provider

When hand-writing YAML, place it in the profile’s ~/.dsh/profiles/<name>/cordis.patch.yml. This acts as an override for the package’s bundled lines (the config block is replaced entirely, not merged). Do not write duplicate insert: entries for the same id: image-once, as this may cause a rollback during the trial start validation. Provider names must match adapter registration names (e.g., commandcode in logs), and models must match the model ID in options.model. Providers not listed in providers are still considered active; if providers is empty, all providers are active.

The plugin config is passed by cordis as the second argument to apply(ctx, config); do not mistakenly write to ctx.config.

Typical Usage

  1. Add the plugin to the current profile using the command above, and turn on the main switch for dsh-image-once in Settings → Plugins.
  2. If using only specific backends or models, enter “Configure,” turn off unnecessary provider rows, or set “Limit Models” for specific rows.
  3. Paste images or use read_image in the conversation normally; images appearing for the first time in a model request are inlined as base64; in subsequent steps of the same session, that occurrence becomes placeholder text.
  4. If the model needs to see details again, it will automatically call read_image based on the placeholder info, and that request will inline it again (a new occurrence).

No additional API calls are required; the behavior is automatically handled during the request projection phase.

Use Cases and Notes

Suitable for: Screenshot-assisted debugging, long conversations after pasting document images, and multi-step agent flows where images are numerous but subsequent reasoning relies mainly on text.

Trade-offs: The model’s “visual content” for each image is only directly visible during the first inlined request. Afterwards, it only knows the sha256, dimensions, filename, and local read-only path. It must call read_image for details (occupying another inline). For “look and then discuss” workflows, this is usually acceptable.

Security and Trust: The plugin rewrites the copy of the request sent to the model and does not persist offload states to session files. It is still recommended to read lib/index.js and the license before installation, and enable it only in trusted profiles.

Development Self-Tests (Within the maintainer’s repository):

node test/run.mjs

Runs host-side tests (request projection, two image shapes, occurrence keys, accounting after the first chunk, etc.) and client-side tests (topic token whitelist, etc.).

Conclusion

dsh-image-once turns the principle of “including image base64 only in the request where the image is inlined” into a toggleable workflow plugin that can be narrowed by provider/model, alleviating the TTFT pressure caused by repeated uploads in long, multi-image conversations. For more information, see the SkillHub Directory Page and the GitHub Repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye