diff --git a/packages/client/ui-conversation/src/client/chat/StatsLine.tsx b/packages/client/ui-conversation/src/client/chat/StatsLine.tsx index 4df819ebd5..c133868b9c 100644 --- a/packages/client/ui-conversation/src/client/chat/StatsLine.tsx +++ b/packages/client/ui-conversation/src/client/chat/StatsLine.tsx @@ -96,6 +96,8 @@ export const StatsLine = memo(function StatsLine({ useSession, useProjection }: const cacheHit = cacheHitPercent(usage) if (cacheHit !== null) parts.push(`cache hit ${cacheHit}%`) } + // contextPercent validates both fields; repeat the capacity guard so that + // TypeScript carries the same refinement into the formatting branch. parts.push(context === null || modelRequest?.contextWindow === undefined ? 'context unknown' : `context ${context}% of ${formatMetricTokens(modelRequest.contextWindow)}`) diff --git a/packages/llm/llm/src/index.ts b/packages/llm/llm/src/index.ts index 6d9102c4a9..220c8bfafa 100644 --- a/packages/llm/llm/src/index.ts +++ b/packages/llm/llm/src/index.ts @@ -448,7 +448,7 @@ export class LlmService extends Service { const resolvedConfig = deepFreeze(structuredClone(resolved.config)) const context = resolved.context === undefined ? undefined - : Object.freeze(structuredClone(resolved.context)) + : deepFreeze(structuredClone(resolved.context)) let dispatched = false return Object.freeze({ config: resolvedConfig,