Awesome Reviewers

When integrating LLM providers, treat model capabilities and token limits as schema-variant inputs and enforce conservative, well-tested limit computation.

Apply: 1) Parse provider model-list metadata defensively

Example:

function contextWindowFromCatalog(entry: Record<string, unknown>) {
  // vLLM commonly uses `max_model_len`.
  const candidates = [
    entry.context_length,
    entry.max_model_len,
    entry.contextWindow,
  ];
  for (const c of candidates) {
    if (typeof c === "number" && Number.isFinite(c) && c > 0) return Math.trunc(c);
  }
  return undefined;
}

2) Select defaults per provider, not globally

3) Compute max-output caps with an intentional policy

Rule of thumb:

4) Recovery retries must separate “attempted” vs “judged”

5) Pin correctness with tests; avoid downstream vendor special-casing

This standard prevents silent regressions like wrong context-window defaults, accidental output-cap reductions that trigger more truncation, and malformed vendor requests caused by ad-hoc special handling.