When developing agents in DeepSeek Harness (DSH), large tasks often face high loop costs, context overflow, or accumulation of tool results. Different task types (such as reading, refactoring, and frontend changes) lack differentiated control, typically requiring reliance on the model itself or static configurations. The dsh-plugin-adaptive-agent-policy plugin published by YuXuanLiang-dev controls prompt and output limits through adaptive task routing, loop budgets, and progressive trimming, without changing the underlying model or tool invocation approach.
Core Capabilities¶
- Multilingual task routing: The plugin includes five task categories:
read,small,frontend,large, andbatch. Routing decisions are based on text analysis and do not trigger LLM calls. - Second-layer risk routing: Runs at soft checkpoints and selects one high-confidence, not-yet-covered check item from nine risk categories (such as
boundary,security, andconcurrency). - Independent budget control: Configures independent “maximum output tokens,” “soft checkpoint steps,” and “plain-text hard final steps” for each task category.
- Non-persistent state: Policy state is stored in a non-persistent system section. It does not append messages to the conversation history, avoiding input accumulation.
- Progressive trimming: Selects one of three trimming levels—
moderate,tight, andcritical—based on step count or context pressure, preserving recent tool results. - Configuration boundary: Exposes only one plugin configuration item externally. The bundled enhanced trimmer uses an independent service name, avoiding conflicts with DSH’s upstream static trimmer.
Installation and Enablement¶
Install the plugin under the web Profile:
dsh plugin --profile web add dsh-plugin-adaptive-agent-policy@next
After installation, check the combined result and start it:
dsh --profile web --dump-config
dsh web
The plugin automatically installs the bundled enhanced trimming service. To adjust the conservatism of the risk router, you can override the configuration item in cordis.patch.yml:
- id: adaptive-agent-policy
config:
riskRouter:
enabled: true
minimumScore: 4
Notes¶
Text routing may conservatively misjudge ambiguous tasks; it intentionally avoids additional routing model calls. The risk router is a heuristic evidence selector; it is not a complete static analysis or security audit. Legacy policy notifications written by rc.2 and earlier versions may still remain in the original conversation history; rc.3 no longer creates new policy history messages. Phase switching changes the system header, which can cause a cache prefix mismatch for that request. Character trimming is not precise token trimming and does not understand the semantic importance of the trimmed content. The plain-text hard final step can limit runaway loops, but it may also truncate tasks that truly require more tool steps.
Summary¶
The plugin applies differentiated control at the system prompt level, helping mitigate context bloat and ineffective loops in large tasks.