---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/context/thrift/subtractive_pass/functions/stripPriorTurnThoughts.md
---

# Function: stripPriorTurnThoughts()

```ts
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](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/thrift/subtractive_pass.ts#L371)

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`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys)<[`WorkingSet`](../interfaces/WorkingSet.md), `"thoughts"`> | A working set exposing (at least) a mutable `thoughts` array; mutated in place. |
| `options`  | [`EstimatorOptions`](../interfaces/EstimatorOptions.md)                                                                                              | The estimator used to measure the tokens reclaimed by dropped thoughts.         |
| `keepIds?` | `ReadonlySet`<`string`>                                                                                                                            | Thought ids to preserve.                                                        |

## Returns

```ts
{
  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](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/thrift/subtractive_pass.ts#L375) |
| `tokens`  | `number` | [src/batteries/context/thrift/subtractive\_pass.ts:375](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/context/thrift/subtractive_pass.ts#L375) |

## 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.
