Skip to content

createIdempotencyKeyBuilder

createIdempotencyKeyBuilder(params): IdempotencyKeyBuilder

Defined in: src/idempotency/key.ts:158

Hands out keys + monotonic stepIds for one conversation. The harness adapter calls .next(intent) once per tool execution.

stepId stability (Q4 hazard). The counter resets to 0 per builder, so a regeneration that replays the conversation from the start reproduces the same stepIds (and therefore the same keys) — covering the “Regenerate” scenario. A partial regeneration that does not replay from step 0 will NOT reproduce them; in that case the harness must pin stepId explicitly via deriveIdempotencyKey. Uncoordinated parallel orchestrators that reuse (conversationId, stepId) for different intents collide — partition them with namespace.

Parameters

params

CreateIdempotencyKeyBuilderParams

Returns

IdempotencyKeyBuilder

Example

import { createIdempotencyKeyBuilder } from "kawasekit/idempotency";
const keys = createIdempotencyKeyBuilder({ conversationId: "conv-42" });
const k0 = keys.next("fetch_weather:Tokyo"); // stepId "0"
const k1 = keys.next("fetch_weather:Osaka"); // stepId "1"