When integrating LLM providers/adapters, treat reasoning and token budgets as provider-specific data shapes and normalize them so downstream systems don’t double-count or receive invalid fields.
Apply these rules: 1) Normalize usage so reasoning tokens are not counted twice.
outputTokens (including nested shapes), subtract those reasoning tokens from outputTokens and track reasoning separately.// Example pattern
const reasoningTokenCount = /* sum across configured reasoning token paths */;
const outputTokens = Math.max(0, normalizedUsage.outputTokens - reasoningTokenCount);
return {
...normalizedUsage,
outputTokens,
reasoningTokenCount,
};
2) Only send reasoning fields that the target backend supports.
3) Map model capability fields correctly to avoid unsafe defaults.
max_model_len) so you don’t silently fall back to an incorrect context/window.4) Make budgeting semantics explicit.
5) Lock the behavior with regression tests at the integration boundary.
This prevents cost/telemetry/session inconsistencies (double-booking), avoids invalid request payloads (backend errors), and reduces the risk of silent capability regressions caused by heterogeneous provider metadata.