Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(llma): skip model metadata tag for non-string values (#60962)

Carlos Marchal4ff97d217fb3
diff --git a/products/ai_observability/frontend/ConversationDisplay/EvaluationDisplay.tsx b/products/ai_observability/frontend/ConversationDisplay/EvaluationDisplay.tsx
index bd29e8be31fc..5bef3fec34ea 100644
--- a/products/ai_observability/frontend/ConversationDisplay/EvaluationDisplay.tsx
+++ b/products/ai_observability/frontend/ConversationDisplay/EvaluationDisplay.tsx
@@ -52,7 +52,7 @@ export function EvaluationDisplay({ eventProperties }: { eventProperties: EventT
{evaluationName}
</MetadataTag>
)}
- {model && (
+ {typeof model === 'string' && model && (
<MetadataTag label="Judge model" textToCopy={lowercaseFirstLetter(model)}>
{lowercaseFirstLetter(model)}
</MetadataTag>
diff --git a/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.test.tsx b/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.test.tsx
new file mode 100644
index 000000000000..be340e0d6f70
--- /dev/null
+++ b/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.test.tsx
@@ -0,0 +1,46 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { initKeaTests } from '~/test/init'
+
+import { MetadataHeader } from './MetadataHeader'
+
+describe('MetadataHeader', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('renders a string model', () => {
+ render(
+ <Provider>
+ <MetadataHeader model="GPT-4o" />
+ </Provider>
+ )
+
+ expect(screen.getByText('GPT-4o')).toBeInTheDocument()
+ })
+
+ const nonStringModels: [string, unknown][] = [
+ ['number', 4],
+ ['boolean', true],
+ ['object', { name: 'gpt-4o' }],
+ ['null', null],
+ ['undefined', undefined],
+ ]
+
+ it.each(nonStringModels)('does not throw for a %s model', (_label, model) => {
+ const { container } = render(
+ <Provider>
+ <MetadataHeader model={model as string} />
+ </Provider>
+ )
+
+ expect(container.textContent).toBe('')
+ })
+})
diff --git a/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.tsx b/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.tsx
index edeef62e3a6f..bdd7d2546a1d 100644
--- a/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.tsx
+++ b/products/ai_observability/frontend/ConversationDisplay/MetadataHeader.tsx
@@ -78,7 +78,7 @@ export function MetadataHeader({
tooltipContent="Prompt tokens written to the provider's cache for reuse on subsequent calls."
>{`${cacheWriteTokens} cache write tokens`}</MetadataTag>
)}
- {model && (
+ {typeof model === 'string' && model && (
<MetadataTag label="Model" textToCopy={lowercaseFirstLetter(model)}>
{model}
</MetadataTag>