DeepSeek Harness

DeepSeek Harness: Integrate a Tool into the Pipeline

· 6 min read · 中文版

A new DeepSeek Harness tool joins the shared execution pipeline through registration; place policy, execution wrappers, result transformations and observation at their documented extension points.

DeepSeek Harness: where does registration meet the pipeline?

The authoring reference registers a defineTool definition through ctx.tools.register in a plugin that injects the tools service. Registration is effect-based and disposing the owning plugin fiber unregisters it. The definition supplies validated parameters, a canonical output schema, a renderer and an execute body. The plugin must also be composed and visible in the intended environment.

The pipeline reference shows what happens around a model call: a tool/call event is recorded before execution, then pre-execution policy and registered guards precede dispatch. A recorded call or pending card is evidence of a request, not proof that the body ran. Denied calls still proceed toward a result, allowing the model to see an outcome.

Registration leads through policy, dispatch and result processing

NeedExtension pointBoundary
Extensible allow, deny or asktools/pre-executeBefore registered guards
Final monotonic denialctx.tools.guard()Deny or abstain; later listeners cannot undo denial
Deadline, retry or metricstools/executeAround dispatch
Replace or block result, add contexttools/post-executeAfter prepared content is projected
Observe authoritative outcometools/resultAfter normalization and finalization

DeepSeek Harness: how do policy and execution interact?

The pre-execution waterfall can allow, deny or ask. An ask goes to ctx.approval; a one-shot approval continues to registered guards, while rejection, cancellation or unavailability skips the body. Even an approved action can be denied by a subsequent guard. Guards are monotonic: use them for owner policy that must not be undone by a later listener. Keep deployment-specific policy in the applicable extension rather than assuming the tool's description enforces it.

After the guards, tools/execute wraps dispatch and can host concerns such as timeout, retry and metrics. The registered execute body performs the actual operation. Treat arguments as readonly and honor exec.signal; the registry protects execution identity and freezes the materialized arguments before policy. An around-dispatch wrapper may replace and restore the signal to impose a deadline, but cannot remove it.

Filesystem read-before-edit checks described in the pipeline sit below tool-fs on fs/* events. Do not assume those exact events cover every shell command or external service call. Each tool's executor and its own policy determine what effects it actually has. Registration and a successful policy decision do not establish that those effects are safe.

DeepSeek Harness: how is a result transformed?

The tool body returns its canonical JSON value matching output.schema. The registry validates and freezes it before output.render produces model-facing content. The pipeline's definition-owned projectContent installs prepared content before tools/post-execute, which can accept, block, replace or add context. Replacing content leaves programmatic access to the value intact; confidentiality policy must block or replace the value when necessary. A rendered explanation is therefore not the only surface to review.

The registry normalizes the candidate outcome and handles snapshot or pipeline errors. The visible definition's finalizeContent then enforces a synchronous content-only invariant. tools/result observes the frozen authoritative outcome, and tool/result records the model-facing result. Active-batch additional contexts are injected after the batch settles and its results are recorded. Observing the final outcome is different from mutating it: choose the extension point that actually has the required authority.

A thrown body, invalid schema value or renderer failure produces an error outcome. A domain result can instead be successful while describing an undesirable state, such as a non-zero process exit. Define this distinction in the output contract so programmatic and model-facing consumers can interpret it consistently.

DeepSeek Harness: how do you integrate and test a tool?

  1. Register the tool with an input schema, canonical output schema, renderer and cancellable body. Confirm composition and visibility for the target caller; use tool development for the definition contract.
  2. Identify the effects of the body and choose the appropriate deployment policy. Use pre-execution for extensible decisions and a registered guard for non-overridable denial where the owning policy requires it.
  3. Add around-dispatch handling only where needed, preserving execution identity and the required signal. Make retries appropriate to the operation's effects; the pipeline's ability to wrap dispatch does not imply every operation is safe to repeat.
  4. Exercise allow, denial and an approval path if applicable. Verify whether the body ran and inspect the resulting tool/result; a pending call and an approval are not completion evidence.
  5. Exercise valid and invalid output, exceptions, cancellation and any post-execution transformation. Verify both the canonical value and model-facing content, then follow the repository and package testing requirements.

PTC mode makes visible registered tools available as await tools.<name>(args) without a separate integration. Sub-calls re-enter the normal pipeline and carry a parent token; success returns final canonical JSON and failure rejects with ToolCallError. The pipeline reference notes that sub-calls omit additionalContexts to preserve call/result adjacency. Test this path if the tool is intended for programmatic use; a human-readable rendering alone is not its complete interface.

DeepSeek Harness: what are the limits and safety boundaries?

A generic policy hook is not a substitute for understanding the tool's real side effects. The filesystem-specific checks belong to their documented tool path, not automatically to every executor. Validate constraints the input schema DSL cannot express and avoid putting secrets in durable metadata or diagnostic examples.

Presentation is separate from execution. Pure Host presenters and durable metadata can support replay, but the built-in Web Client does not consume Host presentCall or presentResult; a specialized Web card needs the client slot described in the authoring reference. Neither a displayed card nor successful schema validation proves the operation was authorized or completed as intended.

DeepSeek Harness: which terms matter?

  • Waterfall: an ordered extension mechanism that can transform or short-circuit the relevant stage.
  • Guard: a monotonic decision that denies or abstains after pre-execution policy.
  • Canonical value: structured JSON returned by the body and validated against its output schema.
  • Projection: preparation of model-facing content from the tool result.
  • Final outcome: the normalized, finalized result observed by tools/result.

Frequently asked questions

Does approval guarantee the body runs?

No. A later registered guard can still deny the call.

Where should final outcomes be observed?

tools/result observes the normalized, finalized and frozen outcome.

Do PTC calls bypass the pipeline?

No. Visible tool sub-calls re-enter the normal execution pipeline.

Sources

Every claim in this article was checked against the sources below. Community discussions are user reports, not official behavior.

  1. Tool Execution Pipeline
  2. Adding A Tool

This is an independent community article, not official DeepSeek documentation. Listing a plugin in the registry is not a security review.

← Back to all articles

DeepSeek Harness: Integrate a Tool into the Pipeline