---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/transformers_js/helpers/interfaces/BatteryLifecycleHooks.md
description: >-
  The opt-in lifecycle option block mixed into each battery's options interface.
  Every phase transition fires {@link onLifecycle} (the firehose) AND the
  matching per-phase hook; subscribe to either or both. All optional — omitting
  them leaves behavior byte-for-byte unchanged.
---

# Interface: BatteryLifecycleHooks

Defined in: [src/batteries/llm/chat\_common/lifecycle.ts:78](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L78)

The opt-in lifecycle option block mixed into each battery's options interface. Every phase transition
fires [onLifecycle](#property-onlifecycle) (the firehose) AND the matching per-phase hook; subscribe to either or both.
All optional — omitting them leaves behavior byte-for-byte unchanged.

## Extended by

* [`TesseractJsOcrAdapterOptions`](../../../../specialists/ocr/tesseract_js/types/interfaces/TesseractJsOcrAdapterOptions.md)
* [`TransformersJsCaptionAdapterOptions`](../../../../specialists/caption/transformers_js/types/interfaces/TransformersJsCaptionAdapterOptions.md)
* [`TransformersJsAdapterOptions`](../../types/interfaces/TransformersJsAdapterOptions.md)
* [`LiteRtLmAdapterOptions`](../../../litert_lm/types/interfaces/LiteRtLmAdapterOptions.md)
* [`TransformersJsGenerationAdapterOptions`](../../../../generation/transformers_js/types/interfaces/TransformersJsGenerationAdapterOptions.md)
* [`TransformersJsEmbeddingsAdapterOptions`](../../../../embeddings/transformers_js/types/interfaces/TransformersJsEmbeddingsAdapterOptions.md)
* [`WebLLMChatCompletionsAdapterOptions`](../../../../interfaces/WebLLMChatCompletionsAdapterOptions.md)
* [`TransformersJsSttAdapterOptions`](../../../../interfaces/TransformersJsSttAdapterOptions.md)

## Properties

| Property                                           | Type                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                       | Defined in                                                                                                                                          |
| -------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `onCompiling?`   | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | Engine/graph/shader compilation after download, before the first token. A COARSE marker: the on-device runtimes (LiteRT `Engine.create`, transformers.js `from_pretrained`) expose the boundary — download done, opaque WebGPU/WASM graph build about to run — but NOT a progress stream, so `progress` is usually absent. Often the slowest part of a cold start; without this it was invisible. | [src/batteries/llm/chat\_common/lifecycle.ts:89](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L89) |
|  `onComplete?`     | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | After the turn's output is parsed + persisted, before `ack` (fires per turn).                                                                                                                                                                                                                                                                                                                     | [src/batteries/llm/chat\_common/lifecycle.ts:95](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L95) |
|  `onError?`           | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | A load or generation failure (paired with `nack`).                                                                                                                                                                                                                                                                                                                                                | [src/batteries/llm/chat\_common/lifecycle.ts:97](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L97) |
|  `onGenerating?` | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | Immediately before the provider generate call (fires per turn).                                                                                                                                                                                                                                                                                                                                   | [src/batteries/llm/chat\_common/lifecycle.ts:93](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L93) |
|  `onLifecycle?`   | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | Fires on EVERY phase transition (the firehose).                                                                                                                                                                                                                                                                                                                                                   | [src/batteries/llm/chat\_common/lifecycle.ts:80](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L80) |
|  `onLoading?`       | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | Weights/runtime loading — may fire repeatedly with `progress` as the provider reports it.                                                                                                                                                                                                                                                                                                         | [src/batteries/llm/chat\_common/lifecycle.ts:82](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L82) |
|  `onReady?`           | [`BatteryLifecycleCallback`](../type-aliases/BatteryLifecycleCallback.md) | Engine/pipeline resolved and cached, before the first generation.                                                                                                                                                                                                                                                                                                                                 | [src/batteries/llm/chat\_common/lifecycle.ts:91](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/llm/chat_common/lifecycle.ts#L91) |
