DeepSeek Harness

How DeepSeek Harness Measures Session Token Pressure

· 6 min read · 中文版

DeepSeek Harness's token meter measures current request pressure from a session's durable event history. It can reuse a qualifying provider-usage anchor or estimate the current request; its totalTokens is not a cumulative lifetime billing total.

DeepSeek Harness: what does the meter measure?

The token meter reference defines a detached TokenMeasurement snapshot for request pressure and positional surface pricing. It records logRevision, the number of durable events consumed for every field, together with a baseline, surfaceDeltaTokens, totalTokens, surfaceTokens and ordered nodes. A snapshot remains immutable when the underlying session advances. A later measurement may therefore differ without changing the earlier snapshot.

totalTokens is non-negative current request-and-response pressure. surfaceTokens is the route-priced total for the current surface alone, equal to the sum of node prices. They are related but not interchangeable. In particular, a pressure snapshot is not defined as the sum of every provider call ever made in the session. Do not use it as a billing ledger without a separate authoritative accounting source.

Provider usage or estimation feeds a session pressure snapshot

DeepSeek Harness: when does provider usage become the baseline?

The meter uses a usage baseline only when the latest successful provider call has the same canonical request envelope and its total is at least that call's full route-priced anchor. Otherwise the baseline is estimated, and the service prices the complete envelope and surface itself. A later successful request replaces the earlier anchor. These conditions prevent an old or insufficient usage value from being treated as a reusable conservative anchor for a different request.

Measurement componentMeaningCommon mistake
logRevisionDurable events consumed for the snapshotAssuming two measurements describe the same session revision
baselineQualifying provider usage or an estimateTreating every measurement as an exact provider count
surfaceDeltaTokensSigned repricing relative to a matching anchorAssuming it can only increase
totalTokensCurrent request-and-response pressureReading it as cumulative billing
surfaceTokensSum of route-priced current surface nodesEquating it with total pressure
nodesCurrent surface in positional orderSorting by event sequence and assuming that is surface order

The signed delta can represent growth or shrinkage relative to the matching anchor, with both sides repriced under the same route. Surface order is authoritative: a replacement node can have a higher durable sequence number than a node appearing later in the surface. The measurement clones the current nodes and is proportional to the surface size.

DeepSeek Harness: how is per-call usage represented?

The LLM streaming reference defines TokenUsage for a provider call. Its counts are disjoint: inputTokens is uncached input, while cache reads and writes are separate. Billed input is the sum of those three categories. Adapters for providers that include cache hits in a single prompt count subtract those hits back out for this representation.

outputTokens includes any reported reasoningTokens; reasoning is informational detail and must not be added a second time. An optional totalTokens is an exact aggregate prompt-plus-output value preserved from the provider or reconstructed from authoritative aggregate counters. It is omitted when unavailable or inconsistent. The per-call TokenUsage.totalTokens and the meter's current pressure field share a name but describe different objects and should be read in context.

Adapters emit a usage chunk before the terminal finish and nothing after finish. The session's compact assistant stream preserves usage and other settlement facts for readers, including token accounting. A failed or aborted attempt should not be silently treated as the latest successful usage anchor; the token-meter rule specifically refers to the latest successful provider call.

DeepSeek Harness: how should I inspect a measurement?

  1. Identify the session and capture the measurement revision. Compare snapshots only after noting whether they describe the same durable tail.
  2. Inspect the baseline kind. A usage baseline has the qualifying conditions above; an estimated baseline means the service priced the envelope and surface rather than reusing such an anchor.
  3. Compare total pressure with surface-only tokens and the signed surface delta. Use the nodes to understand which positions contribute to the current surface.
  4. Check the effective provider and model route when images are involved. A route declaring image pricing supplies visual-token and model-visible-text pricing; otherwise the meter uses its fixed heuristic.
  5. For billing or a completed call's exact usage, consult the provider's accounting and the per-call usage fields. Do not infer lifetime cost from one pressure snapshot.

The measure service can accept an optional request header that replaces the latest logged envelope for pressure and node pricing; the nodes still describe the current session surface. Consequently two measurements of the same session may answer different questions if their effective request headers differ. Keep the route and header context alongside a comparison rather than attributing every difference to new messages.

DeepSeek Harness: how are images and estimates handled?

The meter resolves request-image pricing for the effective provider and model on each measurement. For a declared route, each image occurrence is priced as the visual tokens plus the model-visible text actually sent for that occurrence. Routes without declared pricing retain a fixed heuristic. The streaming reference describes adapter-provided image pricing and notes that provider usage remains the authoritative anchor for completed requests.

This distinction matters after a route change or image offload decision: an occurrence can be represented differently in the request, and the measurement prices the actual projection described by the route. A heuristic is useful for pressure management, but it is not an exact tokenizer or invoice. The documentation does not promise one universal conversion from characters or images to tokens.

DeepSeek Harness: what are the limits and safety boundaries?

The meter is a measurement service, not a spending limit, billing guarantee or proof that a request will fit a provider's context window. An estimate can differ from actual usage, and a snapshot reflects its revision and effective request envelope. Provider-side accounting and pricing must be checked separately when cost matters.

Session content and usage records can reveal sensitive project details. Share only the information needed for an investigation. Avoid assuming that a measurement makes a request safe or that removing a surface node erases all underlying records; the meter describes current pressure, not a data-retention guarantee.

DeepSeek Harness: what do the terms mean?

  • Usage baseline: a qualifying latest successful provider total used as an anchor.
  • Estimated baseline: a measurement priced without a reusable conservative usage anchor.
  • Surface: the current ordered model-facing session content.
  • Request envelope: the effective request configuration and related header state.
  • Log revision: the number of durable session events consumed by the snapshot.

Frequently asked questions

Is meter totalTokens a lifetime bill?

No. It measures current request-and-response pressure.

When is provider usage reused?

When the latest successful call matches the canonical envelope and meets the documented anchor threshold.

Should reasoning tokens be added to output tokens?

No. Reported reasoning tokens are already included in output tokens.

Sources

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

  1. Token meter
  2. LLM streaming

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

How DeepSeek Harness Measures Session Token Pressure