---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/transformers_js/helpers/functions/emitLifecycle.md
---

# Function: emitLifecycle()

```ts
function emitLifecycle(
  hooks: BatteryLifecycleHooks | undefined,
  battery: BatteryLifecycleBattery,
  model: string,
  phase: BatteryLifecyclePhase,
  extra?: Partial<
    Pick<
      BatteryLifecycleReport,
      "error" | "raw" | "detail" | "progress" | "gpuBudget"
    >
  >,
  now?: () => string,
): void;
```

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

Build a [BatteryLifecycleReport](../interfaces/BatteryLifecycleReport.md) (stamping `at`) and dispatch it to the firehose
([BatteryLifecycleHooks.onLifecycle](../interfaces/BatteryLifecycleHooks.md#property-onlifecycle)) AND the per-phase hook for `phase`. A no-op when `hooks`
is undefined or carries no relevant callbacks. Defensive: each callback is invoked through
safeInvoke, so a throwing consumer never disrupts the battery.

## Parameters

| Parameter | Type                                                                                                                                                                                                                                                                                                                            | Description                                                             |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `hooks`   | | [`BatteryLifecycleHooks`](../interfaces/BatteryLifecycleHooks.md) | `undefined`                                                                                                                                                                                                                                             | The merged lifecycle hooks (may be undefined).                          |
| `battery` | [`BatteryLifecycleBattery`](../type-aliases/BatteryLifecycleBattery.md)                                                                                                                                                                                                                                                         | Which battery is emitting.                                              |
| `model`   | `string`                                                                                                                                                                                                                                                                                                                        | Best-effort model id string.                                            |
| `phase`   | [`BatteryLifecyclePhase`](../type-aliases/BatteryLifecyclePhase.md)                                                                                                                                                                                                                                                             | The phase being entered.                                                |
| `extra?`  | [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)<[`Pick`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys)<[`BatteryLifecycleReport`](../interfaces/BatteryLifecycleReport.md), `"error"` | `"raw"` | `"detail"` | `"progress"` | `"gpuBudget"`>> | Optional `detail` / `progress` / `raw` / `error` fields.                |
| `now?`    | () => `string`                                                                                                                                                                                                                                                                                                                  | Injectable clock for tests; defaults to luxon `DateTime.now().toISO()`. |

## Returns

`void`
