﻿# How do you test a per-turn output cap in LiteRT-LM?

How do you test a per-turn output cap in LiteRT-LM? Confirm each turn's effective cap and preserve incomplete state.

Author: Retrivium editorial team
Updated: 2026-11-29
Canonical URL: https://retrivium.ai/journal/research-20261129-litert-output-cap-behavior/
Language: en

LiteRT-LM v0.20.0, released November 23, says litert_lm_main now stops each reply at max_output_tokens when the flag is positive. The release documents the command-line route. Applications should test their own interface and tokenizer.

## What the source establishes

An output limit can end generation even when the model has not finished a JSON object or a sentence. Define how an incomplete output is presented and what is stored in conversation history. Pin the artifact and compare through the same runtime entry point that the application uses.

## Design the comparison

Use a short reply, a reply that reaches the limit and a follow-up turn. Compare generated token counts with the model tokenizer. Repeat on the CLI and any separate integration used in production. Run a representative input with the previous version and repeat it after changing the dependency. Include a nearby boundary and observe the selected execution path.

## Read the results

Check whether the second turn gets its own budget and how the wrapper records completion. A client that only counts displayed text can miss tokens hidden by templates or decoded into empty fragments. Check the returned shape or contract along with time and memory. Keep correctness results attached to the exact configuration. Collect the primary outcome together with a measure of workload size. Preserve errors, timeouts and explicit fallbacks in the reported population. A median from successful samples can conceal a subgroup that operates on a different path. Store enough diagnostic context for another engineer to explain which part of the system caused the difference.

## Decide what goes into service

Confirm each turn's effective cap and preserve incomplete state. Check naturally completed outputs as well as explicit limit stops. State the acceptance threshold before choosing the implementation. Add the tested boundary and conditions for revisiting it to the release record. If an observed behavior differs from expectations, narrow the scope of the rollout while collecting evidence for that case. Keep the prior artifact or configuration available so the comparison remains repeatable.

## Sources

- [Primary source · github.com](https://github.com/google-ai-edge/LiteRT-LM)
- [Primary source · LiteRT-LM v0.20.0](https://github.com/google-ai-edge/LiteRT-LM/releases/tag/v0.20.0)

## Related reading

- [Understand output-token parameters in an OpenRouter adapter](/journal/learn-openrouter-output-token-parameters/)
- [Read OpenRouter normalized and native finish reasons together](/journal/learn-openrouter-finish-reasons/)
