DeepSeek Harness: PTC Runtime and Tool Calls
DeepSeek Harness PTC runtime executes a program with asynchronous host bindings; a tool called through those bindings still travels through the tool execution pipeline. The runtime and the registry solve different parts of the call.
DeepSeek Harness: where does PTC fit?
The PTC runtime reference describes an optional capability, ctx.ptcRuntime, supplied by a provider. It executes one program against host bindings and returns a completion value, captured logs, an error when applicable, and applicable sandbox facts. It is not a mandatory part of the agent-loop spine. The provider determines the supported language, program format and execution environment; consumers should use its own instructions instead of assuming every implementation behaves like the same REPL.
In PTC mode the model-facing transport is run_code, and native tools are available to the program through a tools binding. The tools reference distinguishes the outer transport execution from nested dispatches. A direct model call to a native tool name in this mode has no parent transport token and is denied as UNKNOWN_TOOL before the policy pipeline. A nested tool call has an enclosing execution identity and can enter the regular pipeline. This distinction matters when a tool exists in the registry but a direct call is rejected.
| Component | Main responsibility | What its result means |
|---|---|---|
| PTC provider | Resolve choices and execute the program | Program value, logs, failure and applicable sandbox facts |
| Binding | Bridge an async program call to a host function | Lossless JSON value or rejection |
| Tool registry | Validate and dispatch tool execution through policy | Normalized tool outcome and canonical value |
| Outer transport | Connect the program run to the model call | One enclosing execution with nested call identities |
DeepSeek Harness: what happens before and during a run?
A PtcRunRequest carries the program and binding namespaces, plus optional working directory, timeout, cancellation, sandbox policy and state owner. The provider's resolve checks supported choices and supplies defaults. The resulting PtcRunSpec has an explicit absolute cwd and timeoutMs. An omitted timeout uses provider defaults; a number requests a budget subject to provider validation and capping; null requests no elapsed deadline. An unsupported explicit choice can be rejected before execution, so a request is not evidence that the provider accepted its desired policy.
Each binding namespace becomes a global object of asynchronous callables. The namespace name must follow the documented portable identifier rules and cannot use reserved names. Member names are treated as own properties, including names that could otherwise collide with prototypes. Arguments and resolved values cross a lossless JSON boundary. A host binding rejection becomes a rejection of that call inside the program; a configured error-class descriptor can make the rejection a typed program-visible error.
The runtime does not itself define the semantics of every tool. A registered ToolDefinition owns its execute implementation and mandatory output schema. Successful canonical values are validated against that schema and can be rendered as model-facing content. PTC can receive the structured value of a nested tool, whereas the durable dispatch record can contain a rendered projection. Those representations serve different consumers and should not be assumed to be byte-identical.
DeepSeek Harness: which checks apply to a nested call?
The tool registry materializes and freezes JSON arguments, associates an execution identity and runs the documented sequence: pre-execution policy, monotonic guards, execution wrappers, optional content projection, post-execution policy, final content transformation, and the authoritative result. Guards can reduce permission but cannot turn an earlier denial into permission. Individual tools validate their arguments; the first-party defineTool helper performs validation and type narrowing for definitions that use it.
The nested call carries the root call identity and a parent token. PTC bindings capture the tool schema when constructed and pass it as transient execution metadata. The start and settle records do not serialize that schema. A tools/ptc-dispatch-log listener may reshape the durable copy of rendered content while preserving the program value and outer model-visible result. Thus, when investigating a mismatch, compare the structured tool value, rendered content and logged copy separately rather than assuming a change to one changed all three.
The model-facing schema is also narrower than the host definition. The registry's schemas() uses an explicit allowlist and excludes implementation and presentation fields such as execute and output. Seeing a tool schema tells the model how to call it, but does not expose all scheduling, policy or rendering behavior.
DeepSeek Harness: how do I trace a failed call?
- Confirm that a PTC provider is mounted and inspect its reported language, program format and execution instructions. Determine whether the observed call is the outer
run_codeor a nested call. - Inspect resolution separately from execution. A rejected unsupported choice is different from a program failure returned in
PtcRunResult.error. Check the effective directory and deadline rather than assuming an omitted option means unlimited execution. - For a nested call, check its name, JSON arguments, parent/root identity and the applicable pre-execution and guard decisions. An
UNKNOWN_TOOLon a direct native call in PTC mode is a transport distinction, not necessarily a missing registration. - Compare the tool's validated canonical value with the program's handling and the rendered or durable result. If a binding rejects, inspect the program's error handling as well as the host outcome.
- Examine
logs,value,errorand anysandboxfacts independently. Keep sensitive arguments and tool output out of shared diagnostics. Reproduce with the smallest relevant program and an appropriate test environment.
Program failures resolve as result fields. The documented failure kinds include exception, timeout, abort, worker-exit, invalid-output, output-limit, protocol and sandbox-unavailable. A timeout is distinct from caller cancellation, while a worker exit can indicate the execution substrate died. Invalid or over-limit completion data is a failure rather than a substitute string. Output from each source channel preserves its own order, but interleaving across channels depends on the backend.
Consider a program that calls a registered tool twice and then returns a summary. Each nested dispatch has its own call identity and policy outcome; the program may handle one rejection and continue, or let it become a program exception. The outer run's eventual value describes the program completion, not a guarantee that both nested calls succeeded. Conversely, a successful inner tool does not ensure that the final completion is valid lossless JSON or fits the outer output limit. Record both levels when diagnosing the result.
The tool contract requires asynchronous implementations to observe or forward exec.signal and settle only after their owned work reaches quiescence. The registry preserves caller cancellation when wrappers replace a signal, but cannot hard-kill same-process tool code. This is distinct from the runtime's ability to stop its program: a binding may already have initiated work on the host. Tool authors therefore need cooperative cancellation and correct cleanup even when a program itself has stopped.
A program's console output is also separate from its completion value. The runtime captures text in logs, while the completion crosses the JSON boundary as value when successful. A backend applies its own transport limits to binding calls; the service seam does not declare a uniform binding-byte limit. If a call fails on size, check the actual provider and failure detail instead of inventing a universal threshold.
DeepSeek Harness: what are the limits and safety boundaries?
stateOwner can associate optional in-memory state with object identity; omitting it requests a fresh environment. Stateless providers ignore it, retained state is not durable session state, and consumers must await release(owner) when the owner ends. Cancellation can stop the program even mid-loop, but the caller owns settlement of already in-flight binding calls. Do not assume that aborting the program undoes a tool's external effects.
Sandbox mode, observed denial and reported enforcement completeness are separate facts. The denied flag reflects a diagnostic match, not an exhaustive denial record or proof of enforcement. A successful run, an available tool, or a configured provider does not establish that arbitrary code or its effects are safe. Apply the relevant tool policies and review the actual provider and deployment boundary; the runtime interface does not promise one universal isolation strength.
DeepSeek Harness: what do the terms mean?
- PTC runtime: the optional service that executes a program against host bindings.
- Binding: an asynchronous host function exposed under a program-visible namespace.
- Nested dispatch: a tool execution associated with an enclosing transport call.
- Canonical value: the successful tool-owned JSON value checked against its output schema.
- State owner: an in-process identity for optional retained runtime state, not durable history.
Frequently asked questions
Does PTC replace the tool registry?
No. Host bindings can dispatch nested calls through the tool execution pipeline.
Is a program failure always a rejected promise?
No. Program failures are reported in PtcRunResult.error; invalid inputs can reject before execution.
Does abort undo an in-flight tool call?
No such rollback is promised; the caller owns settlement of in-flight binding calls.
Sources
Every claim in this article was checked against the sources below. Community discussions are user reports, not official behavior.
This is an independent community article, not official DeepSeek documentation. Listing a plugin in the registry is not a security review.