Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(llm-proxy): read the catalog name as a bounded display name (#739)

Alfredo Lopezb01c7d9c818d
diff --git a/codex-llm-proxy/test/catalogContextWindow.test.ts b/codex-llm-proxy/test/catalogContextWindow.test.ts
index 9222cc997..e0473f2b3 100644
--- a/codex-llm-proxy/test/catalogContextWindow.test.ts
+++ b/codex-llm-proxy/test/catalogContextWindow.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { readFileSync } from 'node:fs'
-import { listCodexModels } from '../src/codexTransport.js'
+import { CATALOG_LIMITS, listCodexModels } from '../src/codexTransport.js'
const lookup = async () => [{ address: '1.2.3.4', family: 4 }]
@@ -73,3 +73,52 @@ describe('Codex catalog context window (#731 R3-4)', () => {
])
})
})
+
+describe('Codex catalog display name (#739 R9-8)', () => {
+ async function list(rows: unknown[]) {
+ return listCodexModels({
+ accessToken: 'tok',
+ fetchFn: (async () => jsonResponse({ models: rows })) as typeof fetch,
+ lookup,
+ })
+ }
+
+ it('T-R9-8b reads name after displayName, title and display_name', async () => {
+ const listed = await list([
+ { slug: 'a', displayName: 'Camel', title: 'Title', display_name: 'Snake', name: 'Name' },
+ { slug: 'b', title: 'Title', display_name: 'Snake', name: 'Name' },
+ { slug: 'c', display_name: 'Snake', name: 'Name' },
+ { slug: 'd', name: 'Name' },
+ ])
+ expect(listed.models.map(row => [row.model, row.displayName])).toEqual([
+ ['a', 'Camel'],
+ ['b', 'Title'],
+ ['c', 'Snake'],
+ ['d', 'Name'],
+ ])
+ })
+
+ it('T-R9-8c omits a display name over the bound instead of truncating it', async () => {
+ expect(CATALOG_LIMITS.maxDisplayNameLength).toBe(256)
+ const max = CATALOG_LIMITS.maxDisplayNameLength
+ const listed = await list([
+ { slug: 'at-bound', display_name: 'n'.repeat(max) },
+ { slug: 'over-snake', display_name: 'n'.repeat(max + 1) },
+ { slug: 'over-name', name: 'n'.repeat(max + 1) },
+ { slug: 'over-camel', displayName: 'd'.repeat(max + 1), name: 'Short' },
+ ])
+ // Witness: every row was listed, so the omission is per field, not per row.
+ expect(listed.models.map(row => row.model)).toEqual([
+ 'at-bound',
+ 'over-snake',
+ 'over-name',
+ 'over-camel',
+ ])
+ expect(listed.models.map(row => row.displayName)).toEqual([
+ 'n'.repeat(max),
+ undefined,
+ undefined,
+ undefined,
+ ])
+ })
+})
diff --git a/grok-llm-proxy/test/catalogContextWindow.test.ts b/grok-llm-proxy/test/catalogContextWindow.test.ts
index 171191cc5..8a291ae9b 100644
--- a/grok-llm-proxy/test/catalogContextWindow.test.ts
+++ b/grok-llm-proxy/test/catalogContextWindow.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { readFileSync } from 'node:fs'
-import { listGrokModels } from '../src/grokTransport.js'
+import { CATALOG_LIMITS, listGrokModels } from '../src/grokTransport.js'
const lookup = async () => [{ address: '1.2.3.4', family: 4 }]
@@ -54,3 +54,55 @@ describe('Grok catalog context window (#731 R3-4)', () => {
])
})
})
+
+describe('Grok catalog display name (#739 R9-8)', () => {
+ async function list(rows: unknown[]) {
+ return listGrokModels({
+ accessToken: 'tok',
+ fetchFn: (async () => jsonResponse({ data: rows })) as typeof fetch,
+ lookup,
+ })
+ }
+
+ it('T-R9-8a-grok keeps the recorded name as displayName', async () => {
+ const listed = await listGrokModels({
+ accessToken: 'tok',
+ fetchFn: (async () => jsonResponse(recorded)) as typeof fetch,
+ lookup,
+ })
+ expect(listed.outcome).toBe('ready')
+ expect(listed.models.map(row => [row.model, row.displayName])).toEqual([
+ ['grok-4.6', 'Grok 4.6'],
+ ])
+ })
+
+ it('T-R9-8b-grok reads name after displayName and title', async () => {
+ const listed = await list([
+ { id: 'a', displayName: 'Camel', title: 'Title', name: 'Name' },
+ { id: 'b', title: 'Title', name: 'Name' },
+ { id: 'c', name: 'Name' },
+ ])
+ expect(listed.models.map(row => [row.model, row.displayName])).toEqual([
+ ['a', 'Camel'],
+ ['b', 'Title'],
+ ['c', 'Name'],
+ ])
+ })
+
+ it('T-R9-8c-grok omits a display name over the bound instead of truncating it', async () => {
+ expect(CATALOG_LIMITS.maxDisplayNameLength).toBe(256)
+ const max = CATALOG_LIMITS.maxDisplayNameLength
+ const listed = await list([
+ { id: 'at-bound', name: 'n'.repeat(max) },
+ { id: 'over-name', name: 'n'.repeat(max + 1) },
+ { id: 'over-camel', displayName: 'd'.repeat(max + 1), name: 'Short' },
+ ])
+ // Witness: every row was listed, so the omission is per field, not per row.
+ expect(listed.models.map(row => row.model)).toEqual(['at-bound', 'over-name', 'over-camel'])
+ expect(listed.models.map(row => row.displayName)).toEqual([
+ 'n'.repeat(max),
+ undefined,
+ undefined,
+ ])
+ })
+})