Function: stripPriorTurnThoughts()
function stripPriorTurnThoughts(
ws: Pick<WorkingSet, "thoughts">,
options: EstimatorOptions,
keepIds?: ReadonlySet<string>,
): {
dropped: number;
tokens: number;
};Defined in: src/batteries/context/thrift/subtractive_pass.ts:371
Gemma model card §3 — "No Thinking Content in History": thoughts from previous model turns MUST NOT be re-added before the next user turn. Enforced here as a standalone, callable step (not a silent battery-wide flag), because it is also pure thrift: prior-turn reasoning is the highest-volume, lowest-reuse content a working set carries.
Parameters
| Parameter | Type | Description |
|---|---|---|
ws | Pick<WorkingSet, "thoughts"> | A working set exposing (at least) a mutable thoughts array; mutated in place. |
options | EstimatorOptions | The estimator used to measure the tokens reclaimed by dropped thoughts. |
keepIds? | ReadonlySet<string> | Thought ids to preserve. |
Returns
{
dropped: number;
tokens: number;
}How many thoughts were dropped, and how many tokens that reclaimed.
| Name | Type | Defined in |
|---|---|---|
dropped | number | src/batteries/context/thrift/subtractive_pass.ts:375 |
tokens | number | src/batteries/context/thrift/subtractive_pass.ts:375 |
Remarks
keepIds is an allow-list of thought ids to PRESERVE — used for e.g. a planner's synthetic THIS-TURN plan thought, which is fresh guidance generated for the current request (NOT prior-turn chain-of-thought, and NOT subject to the §3 policy): it must survive into the next dispatch's prompt so the model follows the plan. Everything else is dropped.
subtractToFit calls this internally as step 1 (gated by its stripPriorTurnThoughts option, default true); it is also exported standalone for a caller who wants the strip without running the rest of the pass.