Introduction

When DSH’s llm-pi-ai does not declare a contextWindow, it falls back to a default of 262144 tokens. If a local llama.cpp server is started with -c 65536, the default setting becomes too large, causing the built-in compression mechanism to fail and the first long request to immediately trigger a 400 overflow error. iyicode/dsh-ctx-probe solves this configuration mismatch by probing the server’s actual runtime context window in real time.

Core Features

The plugin probes the server’s actual runtime context window every time an agent/request is triggered, supporting both llama.cpp and Ollama servers.

It implements bidirectional automatic synchronization: if the probed value is smaller than the current setting, it automatically tightens the configuration to prevent overflow; if the probed value is larger, it automatically relaxes the configuration to follow server-side growth. For local servers (localhost, etc.), re-probing is performed for every request, while remote servers use a TTL cache of approximately 10 minutes.

To prevent probe storms, the plugin uses a single-flight strategy combined with exponential backoff, starting with a 10-second interval and capped at 5 minutes. The plugin is fully self-contained and does not depend on any @deepseek-ai/* packages.

Installation

Install using the Web profile:

dsh plugin --profile web add https://github.com/IYIcode/dsh-ctx-probe

Installing a bundle is a startup-time change. You must restart the DSH Web Host (stop it first with Ctrl+C before running dsh web) for the change to take effect.

Usage

Check the current probe status:

/ctx-probe force

This command displays three window values for the target provider/model: configured (configured value), effective (effective value), and probed (probed value).

Send any message to a local model. The plugin will probe the server’s actual n_ctx before the request and synchronize the settings automatically, without any manual intervention.

Notes

If installation fails with the error "declares no dsh.bundle", it may be caused by a network issue. Check the source or use a local directory source if necessary.

Probe failures will not disrupt the agent loop; errors are handled silently.