Skip to content
2 min read · 323 words

Interface: WorkingRetrievable

Defined in: src/batteries/context/thrift/contracts.ts:134

The structural shape of a retrieved passage (RAG chunk) the working set carries. estimateTokens mirrors a core Retrievable's own method, which MAY resolve asynchronously (a reader-backed artifact's estimate can be a Promise) — the battery treats a non-number return as "measure the rendered string instead" (see @nhtio/adk/batteries/context/thrift/subtractive_pass!subtractToFit's rTok helper), since this pass is synchronous end-to-end and never awaits.

Properties

PropertyTypeDescriptionDefined in
content| string | { estimateTokens?: number | Promise<number>; toString: string; }The retrieved passage's rendered content. Core artifacts may expose an asynchronous estimate; thrift only accepts the synchronous result and otherwise uses its defensive fallback.src/batteries/context/thrift/contracts.ts:139
id?stringStable identifier, when available, for diagnostics and trace attribution.src/batteries/context/thrift/contracts.ts:136
score?numberRelevance/rerank score, [0, 1]-ish; retrievables sort by this (descending) before the shed, so the tail of the ranking (lowest score) sheds first. Missing/absent sorts as 0 (shed first).src/batteries/context/thrift/contracts.ts:147
sizeUnknown?booleanWhether this retrievable's content cannot be synchronously measured safely by thrift. A real core Retrievable structurally supplies this field automatically through its sizeUnknown getter; no adapter or conversion object is needed. Any other, non-core duck-typed caller supplying this shape MUST set sizeUnknown: true for content whose size it cannot verify to receive the same never-retain safety guarantee. This field is optional only to preserve the structural API's compatibility; the obligation for such callers is not enforced by TypeScript.src/batteries/context/thrift/contracts.ts:161

Methods

estimateTokens()?

ts
optional estimateTokens(encoding: string): number | Promise<number>;

Defined in: src/batteries/context/thrift/contracts.ts:150

Optional self-measurement; may resolve synchronously OR as a Promise (a reader-backed artifact). A non-number result falls back to measuring content.toString().

Parameters

ParameterType
encodingstring

Returns

number | Promise<number>