Awesome Reviewers

Telemetry must be (a) policy-compliant, (b) causally correct in time, and (c) semantically accurate in meaning—so monitoring never turns “what happened” into “something close”.

Apply the following standards:

1) Respect telemetry policy boundaries

2) Avoid causal ordering races

3) Ensure semantic accuracy of “reasons” and attribution

4) Lock behavior with tests that assert the telemetry contract

Minimal example pattern (causal + semantic correctness):

// Bad: recording happens after a lifecycle close can already end observation.
stream.onEnd(() => {
  if (event.finishReason === "error") {
    captureError(lateError); // can arrive too late
  }
});

// Better: record the error in the hook that runs before the generation span closes.
stream.onError(() => {
  pendingError = currentError;
});
stream.onLanguageModelCallEnd(() => {
  if (pendingError) recordError(pendingError); // ensure generation span gets exception
});

If you’re adding/changing telemetry, ask: