tool-deadline-guard: Adds deployment-level deadline to tool calls without declared timeoutMs

Preface

When running long tasks in DeepSeek Harness (dsh), a common phenomenon occurs: the turn in the UI displays “running” indefinitely, while the logs and output show no errors. The model side has a streaming idle timeout (DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300_000, reloaded per chunk by idleWatchdog), so “long periods of no output” often point to a stuck tool call rather than a stuck model. Community discussion #7339 describes this type of silent hang in long-horizon tasks.

One of the root causes lies in tool definitions: ToolDefinition.timeoutMs is an optional field, described as “Cooperative tool-call timeout budget in milliseconds. Omit for no deadline”. The core policy package @deepseek-ai/dsh-tool-call-timeout-policy simply executes return next() when timeoutMs === undefined; it does not set a timer, send a signal, or write diagnostics. In dsh v0.1.6-alpha.2, among the 40 non-test source files calling defineTool(, 26 have no timeoutMs at all. This includes tool-subagent, tool-terminal, mcp-resources, and several fs and workflow-related tools—precisely the paths prone to long-term blocking, such as delegating to subprocesses or cross-network MCP calls.

The following introduces the community Cordis plugin @argszero/cordis-plugin-tool-deadline-guard (GitHub: argszero/cordis-plugin-tool-deadline-guard). It adds a configurable, deployment-level budget to calls that do not “self-declare a deadline” on the tools/execute and tools/pre-execute waterfalls. Upon timeout, it converts the silent hang into a structured error visible to the model, facilitating retries or strategy changes.

What is this

@argszero/cordis-plugin-tool-deadline-guard is published by the maintainer argszero and categorized as a workflow-oriented plugin within the DSH ecosystem (SkillHub Directory: argszero/cordis-plugin-tool-deadline-guard). It does not replace the timeoutMs implemented by the tool itself; instead, it times the tool execution body and the pre-dispatch phase separately when the harness has not armed any deadline. Upon expiration, it returns a plugin-specific error code, distinguished from the core policy’s TOOL_TIMEOUT, making it easy to distinguish between “the tool declared a budget but timed out” and “the budget added by deployment policy timed out”.

Core Features

Execution Phase (tools/execute)

The plugin hooks into the same public seam tools/execute as the core timeout policy. For each dispatch:

  1. Resolve the tool definition via ctx.tools.get(exec.name, exec.agent) to determine whether to arm the deadline; unknown tools are still handled by the registry (UNKNOWN_TOOL).
  2. Arm a timer and an AbortController, providing the tool with AbortSignal.any([caller, own]) via exec.signal, consistent with the core policy’s approach.
  3. Restore the caller’s signal in the finally block to prevent subsequent wrappers from seeing a signal that may have been aborted by this mount.
  4. Only replace the result if this mount’s timer triggers first; if the call finishes normally within the budget, the tool result is returned as-is without a secondary dispatch.
  5. The timeout result takes the form isError: true with error.info.code === 'TOOL_DEADLINE_EXCEEDED' (not the core TOOL_TIMEOUT), allowing the model side to act accordingly. An example in the README shows a call to subagent returning an error text explicitly stating the source of the deadline when it exceeds 600000ms and the tool has not declared timeoutMs.

By default, any call that does not specify timeoutMs in the tool definition is bound to 10 minutes (600000 ms). Tools that have declared timeoutMs are still handled by the core policy under the default applyTo: undeclared, and this plugin does not alter them.

Pre-dispatch Phase (tools/pre-execute, 0.2.0)

timeoutMs only constrains the tool body; the tools/pre-execute waterfall completes before the core tools/execute wrapper. If a listener awaits unbounded work during this phase, tool calls for the entire session will be blocked behind it, and a deadline hooked only onto tools/execute structurally cannot see this phase. The README cites @deepseek-ai/dsh-workspace-changes waiting for a turn recorder snapshot queue in pre-execute as an example, pointing to discussion #9515.

Starting from 0.2.0, the same plugin also hooks into tools/pre-execute. Timeouts in this phase use a different error code, TOOL_PRE_EXECUTE_DEADLINE_EXCEEDED, taking the form of a denial (the call is not dispatched), distinguishing it from execution timeouts: this helps determine whether the issue is “ran too long” or “did not run at all”.

Configuration Options

Without configuration: a default budget of 10 minutes is applied to all tools that do not declare timeoutMs, and other calls are passed through as-is.

field default meaning
mode auto auto arms the deadline; observe only reports what would be bound and dispatches as-is; off does not register
defaultTimeoutMs 600000 Budget for tools that have not declared a timeout (10 minutes)
perTool {} Override budgets by resolved tool name, taking precedence over defaultTimeoutMs
exempt [] Tool names that are never bound
applyTo undeclared undeclared does not touch tools that have declared timeoutMs; all bounds all known tools
onExpiry cooperative Behavior on expiration; the README points to the “Honest limits” section
preExecute true Whether to bound the pre-dispatch phase
preExecuteTimeoutMs defaultTimeoutMs Budget for the pre-dispatch phase
warnLimit 5 Number of diagnostic entries emitted per mount; 0 disables

The budget must be a positive finite number and ≤ 2147483647 (the saturation upper limit of setTimeout); larger values will trigger immediately. Therefore, “no deadline” should be expressed via exempt or mode: off, rather than setting an extremely large value.

Installation and Enablement

First, install the npm package in your project (version based on the registry; currently 0.2.0 in package.json):

npm install @argszero/cordis-plugin-tool-deadline-guard

Add a line in cordis.yml or your profile bundle (you can also merge the included cordis.patch.yml, which is equivalent):

- insert:
    - id: tool-deadline-guard
      name: '@argszero/cordis-plugin-tool-deadline-guard'

It takes effect without additional configuration after installation: tools that do not declare timeoutMs have a default upper limit of 10 minutes. To require longer or shorter waits, adjust defaultTimeoutMs or perTool in the Cordis plugin configuration; for tools that must allow long-term blocking (e.g., specific MCPs), add their names to exempt.

Before going live, you can use mode: observe to see which calls this mount would bound, then switch back to auto after confirming the list.

Typical Usage Examples

Only tighten subagent and terminal, keeping the default 10 minutes for others:

Configure on the plugin instance (field names based on README):

defaultTimeoutMs: 600000
perTool:
  subagent: 900000
  terminal: 300000
exempt:
  - ask-user

Disable pre-dispatch phase bound (only guard execution body):

preExecute: false

Fully exempt a specific third-party MCP tool:

exempt:
  - mcp_some_server_long_poll

Upon timeout, the model will see a tool_result [error] similar to the one in the README, explaining the exceeded milliseconds and that the deadline came from the tool-deadline-guard mount, not the tool’s own timeoutMs.

Applicable Scenarios and Notes

Who it is for: Teams using dsh in production or long-duration automated tasks that rely on subagent, terminal, MCP, or workflow-type tools; teams that want turns to avoid infinite “running” due to a single wedged call, while needing to distinguish operational semantics from the core TOOL_TIMEOUT (deployment policy vs. tool self-declared budget).

Cooperative default: onExpiry defaults to cooperative; the README emphasizes that the plugin will not forcibly discard calls that the tool itself is unwilling to end, and clearly explains limitations in the optional replace mode. For more aggressive behavior, read the README’s “Honest limits”.

Permissions and Security: The plugin runs with the current dsh process’s permissions and hooks into the harness’s public waterfall without separate privilege reduction. Please read the GitHub repository source code and MIT license before installation to ensure compliance with your requirements. The peer dependency range is audited in the package description as the npm/pnpm prerelease reading of dsh 0.1.2-rc.1 to 0.2.1-alpha.2; if it does not match your actual dsh version, verify in a test environment.

Ecosystem Notes: DSH adopts the “everything is a plugin” Cordis composition approach; community directories like SkillHub are independent of DeepSeek / High-Flyer and are not official app stores. This plugin has 0 stars (as of the directory snapshot); selection should be based on the README and issue tracking for maintenance status.

Conclusion

tool-deadline-guard addresses the gap where the harness has no default deadline for tools with “undeclared timeoutMs”: it converts silent wedged tool calls into TOOL_DEADLINE_EXCEEDED or TOOL_PRE_EXECUTE_DEADLINE_EXCEEDED, allowing both the model and operations to see the cause. Directory page: https://www.skillhub.cn/plugins/argszero/cordis-plugin-tool-deadline-guard; Source code and full configuration instructions: https://github.com/argszero/cordis-plugin-tool-deadline-guard.

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

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

Xiaoye