Preface¶
When running long sessions in DeepSeek Harness (DSH), agents frequently use job_output with wait: true to monitor background tasks, or use run_code to re-check logs and processes. The default tools have their own timeouts, but models tend to treat the single-call limit as a budget for “waiting one more round,” stacking up dozens of minutes of blocking in a single turn. Another class of issues is: the answer is actually ready, but subsequent steps are left with only status probes or empty run_code, and users cannot see a text response, only the stop button.
This behavior can be mitigated without modifying the tool implementation itself: by wrapping a layer of strategy before and after tool execution to reject waiting beyond the budget, circuit-break continuous polling with no progress, and clearly write out the reason upon deadline or parsing failure. dsh-wait-guard is a DSH plugin for this workflow. Maintained by Lion-Li-git, current version 0.3.2 (2026-11-15), license MIT.
What is it¶
dsh-wait-guard intervenes in the call chain via the host plane’s tools/pre-execute / tools/post-execute, without modifying any tool bodies. It primarily does seven things: limit the waiting budget for job_output with wait; intercept foreground commands nested in run_code that would hit the program deadline; append explanations when run_code is slow or triggers an execution deadline; circuit-break consecutive “status check only” probes; circuit-break consecutive no-op run_code calls; prompt for template string backtick issues on common JS parsing errors; and for loops that repeatedly ignore no-op refusals, forcibly abort the turn and optionally auto-recover a plain text followup.
The plugin is categorized as “Workflow” in the SkillHub community directory and has no official affiliation with DeepSeek/Huasuan; users should check the GitHub source code and license before installing. The plugin runs with the current DSH process permissions.
Core Features¶
job_output Waiting Budget¶
For calls to job_output with wait: true:
- Single wait no more than 20 seconds (configurable
perCallMaxMs). - Only allowed to wait within 2 minutes of task start (
youngMs, default 120000). - Total cumulative wait for the same task no more than 40 seconds (
totalBudgetMs). - When the caller does not pass
timeout_ms, usedefaultWaitMs(default 30000) for calculation.
Calls exceeding the budget will be rejected immediately (~1ms level), and the rejection reason will state that the turn should end or wait for completion notification, rather than continuing to block.
The long-session real-world test cited in the README (session b3a09167, 4 days) saw 59 wait: true calls with a total blocking of about 5447 seconds; 52 of them used timeout_ms: 115000, getting close to the 120-second program limit loop waiting. Default parameters are set based on this data.
run_code and Foreground Timeout Relationship¶
If the foreground pwsh timeoutMs nested inside run_code exceeds the program deadline of run_code (default programDeadlineMs: 120000), the call will be rejected directly—such a command would be terminated at the deadline point, and continuing to wait is meaningless.
If the program occupies the foreground for more than 45 seconds (slowProgramMs), or the result contains execution deadline reached, an explanation will be appended after the result: that is the run_code program’s own budget (configurable), not the task’s total limit; long-running tasks should use run_in_background and then end the turn.
State Polling Circuit-Breaker¶
If the same agent performs “status check only” 4 times in a row within a 120-second window (probeWindowMs), it will be denyd. Heuristic determinations include: the body of run_code or direct pwsh commands only reading job status, log tail, process list, or clock with no write operations; direct job_output without wait also counts. Work-oriented calls like git add, npm run, write/edit reset the counter; exceeding the window or entering a new turn also resets it. Only denies, does not cancel the turn; starting from the second denial, the reason escalates to “subsequent probes will be denied”.
The Epirus-Web session example in the README (session 04e0a3ef): a turn with a complete answer still has many steps of only checking logs/processes and 0 assistant text, belonging to the same class of problems.
No-op run_code Circuit-Breaker and Forced Recovery¶
If the same agent performs “doing nothing” 3 times in a row within 120 seconds (noopLimit), it will be rejected: description is No-op, program is empty/only return/only console.log("constant"), etc. The rejection reason requires not calling tools again and directly writing the final answer into assistant text. Work calls reset the no-op counter; status probes do not reset the no-op counter, so alternating idle calls and status checks will still count. New turn resets it.
If the no-op continues to loop after being denied the second time, the plugin will cancel the current turn (keepInbox) and followup a user message with “output text only, direct answer”; automatic recovery is limited to once every 120 seconds. After that, if it spins again, it will only abort, no longer auto-followup. Status probes do not follow this path.
Starting from 0.3.2: status probes no longer cancel the turn; status/no-op counters are reset per turn to avoid the previous turn’s probes from mistakenly affecting new tasks.
JS Parsing Error Hints¶
When run_code errors contain Expected ',', got 'ident', Unexpected token, or Invalid or unexpected token, a “template literal backtick” hint will be appended, and the count of backticks inside the program will be tracked (PowerShell’s `t / `n or Markdown backticks might prematurely end JS templates).
Installation and Enablement¶
Install under the target profile (commands from official README):
dsh plugin --profile <profile> add dsh-wait-guard
# or install directly from GitHub
dsh plugin --profile <profile> add github:Lion-Li-git/dsh-wait-guard
After installation, a new session will take effect: the bundle patch will mount a line wait-guard.
Environment requirements: DSH >=0.2.0, cordis >=4, Node >=22.19; no runtime dependencies, pure ESM.
Configuration¶
In the profile’s cordis.patch.yml, add config to the wait-guard entry (unit: milliseconds, all optional):
- id: wait-guard
config:
perCallMaxMs: 20000 # Single wait limit
youngMs: 120000 # Only allow waiting for tasks "younger" than this
totalBudgetMs: 40000 # Total cumulative wait limit for the same task
defaultWaitMs: 30000 # Use this when caller doesn't pass timeout_ms
slowProgramMs: 45000 # Append slow hint when run_code exceeds this
programDeadlineMs: 120000 # Default program deadline for run_code
probeLimit: 4 # Start rejecting on the Nth consecutive status probe
probeWindowMs: 120000 # Probe/idle call counting window; resets after exceeding
noopLimit: 3 # Start rejecting on the Nth consecutive no-op run_code
Typical Usage and Behavioral Boundaries¶
The plugin has no separate “business API”: after installing and enabling it on the profile, the strategy automatically applies to tool calls initiated by the model. Commands run manually in the terminal are not affected.
When developing the plugin itself, the test method in the repository is:
npm test
node --test covers use cases such as probe rejection and escalation, work command resets, isolation of wait: true and probe counts, nested pwsh timeouts, no-op circuit-breaking, cancel/followup, new turn counter resets, and parsing errors/deadline hints.
When using, please note the side effects and limitations declared in the README:
- Fail fast/pass through: when jobs service cannot be found, tool name does not match, or parameters are malformed, always
next()to avoid false positives. - Rejection may abort the current
run_codeprogram (uncaughtToolCallError), and any side effects already generated will not be rolled back. - Status probes and no-ops are both heuristic: for example,
node -ereading logs might not be recognized as a probe. - Only affects calls initiated by the model.
Applicable Scenarios¶
Suitable for developers who frequently run long tasks in DSH and rely on job_output and run_code: needing to limit “waiting” and “polling” within a predictable budget, and reducing “having an answer but no text” or spinning tool chains consuming turns.
If you almost never use background jobs or never check status consecutively, the plugin will still be mounted on the chain, but the trigger surface might be very small; thresholds can be adjusted in cordis.patch.yml or the plugin can be uninstalled as needed.
Links¶
- Community Directory: dsh-wait-guard (SkillHub)
- Source code and detailed description: github.com/Lion-Li-git/dsh-wait-guard
Through the steps above, you can make waiting, status polling, and empty run_code have clear brakes without significantly modifying the workflow, while retaining space for normal tool calls.