mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
Classify legacy model fallbacks from agent probe metadata
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
import { agentPickerModelMenu } from '../../../../shared/agent-launch/picker/agent-launch-picker-catalog'
|
||||
import { beforeEach, expect, it, vi } from 'vitest'
|
||||
const mocks = vi.hoisted(() => ({ discover: vi.fn(), structured: vi.fn() }))
|
||||
vi.mock('@/runtime/source-control/git/runtime-git-generation-client', () => ({
|
||||
discoverRuntimeCommitMessageModels: mocks.discover
|
||||
vi.mock('@/runtime/native-chat/model-catalogs/terminal-model-discovery-client', () => ({
|
||||
discoverRuntimeTerminalModels: mocks.discover
|
||||
}))
|
||||
vi.mock('@/runtime/native-chat/requests/structured-agent-session-call', () => ({
|
||||
callStructuredAgentSession: mocks.structured
|
||||
@@ -31,7 +31,9 @@ beforeEach(() => {
|
||||
})
|
||||
|
||||
it('consumes legacy rows without claiming a configured default and separates fallback from verified empty', () => {
|
||||
expect(cliModelCatalogAnswer({ ...cliResult, catalogOrigin: undefined })).toMatchObject({
|
||||
expect(
|
||||
cliModelCatalogAnswer('antigravity', { ...cliResult, catalogOrigin: undefined })
|
||||
).toMatchObject({
|
||||
origin: 'probe',
|
||||
listingNamesConfiguredModel: false,
|
||||
models: [
|
||||
@@ -41,14 +43,18 @@ it('consumes legacy rows without claiming a configured default and separates fal
|
||||
{ id: 'claude-sonnet-4-6' }
|
||||
]
|
||||
})
|
||||
expect(cliModelCatalogAnswer({ ...cliResult, catalogOrigin: 'spec' })).toBeUndefined()
|
||||
expect(cliModelCatalogAnswer({ success: false, error: 'unsupported' })).toBeUndefined()
|
||||
expect(cliModelCatalogAnswer({ ...cliResult, models: [] })).toMatchObject({
|
||||
expect(
|
||||
cliModelCatalogAnswer('antigravity', { ...cliResult, catalogOrigin: 'spec' })
|
||||
).toBeUndefined()
|
||||
expect(
|
||||
cliModelCatalogAnswer('antigravity', { success: false, error: 'unsupported' })
|
||||
).toBeUndefined()
|
||||
expect(cliModelCatalogAnswer('antigravity', { ...cliResult, models: [] })).toMatchObject({
|
||||
origin: 'probe',
|
||||
models: []
|
||||
})
|
||||
expect(
|
||||
cliModelCatalogAnswer({ ...cliResult, catalogOrigin: undefined, models: [] })
|
||||
cliModelCatalogAnswer('antigravity', { ...cliResult, catalogOrigin: undefined, models: [] })
|
||||
).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -152,10 +158,10 @@ it('settles unsupported terminal source routes without leaving a listing placeho
|
||||
})
|
||||
|
||||
it('does not promote the legacy Config default fallback into a terminal operand', () => {
|
||||
const answer = cliModelCatalogAnswer({
|
||||
const answer = cliModelCatalogAnswer('antigravity', {
|
||||
...cliResult,
|
||||
catalogOrigin: undefined,
|
||||
models: [{ id: 'default', label: 'Config default' }],
|
||||
models: [{ id: 'default', label: 'Changed or translated label' }],
|
||||
defaultModelId: 'default'
|
||||
})
|
||||
expect(answer).toBeUndefined()
|
||||
@@ -180,7 +186,7 @@ it('publishes only changed CLI rows, independent of the clock', () => {
|
||||
target,
|
||||
'antigravity',
|
||||
'id:x',
|
||||
cliModelCatalogAnswer(cliResult)!,
|
||||
cliModelCatalogAnswer('antigravity', cliResult)!,
|
||||
'cli'
|
||||
)
|
||||
notices.mockClear()
|
||||
@@ -189,7 +195,7 @@ it('publishes only changed CLI rows, independent of the clock', () => {
|
||||
target,
|
||||
'antigravity',
|
||||
'id:x',
|
||||
cliModelCatalogAnswer(cliResult)!,
|
||||
cliModelCatalogAnswer('antigravity', cliResult)!,
|
||||
'cli'
|
||||
)
|
||||
expect(notices).not.toHaveBeenCalled()
|
||||
@@ -197,7 +203,10 @@ it('publishes only changed CLI rows, independent of the clock', () => {
|
||||
target,
|
||||
'antigravity',
|
||||
'id:x',
|
||||
cliModelCatalogAnswer({ ...cliResult, models: [{ id: 'new-model', label: 'New model' }] })!,
|
||||
cliModelCatalogAnswer('antigravity', {
|
||||
...cliResult,
|
||||
models: [{ id: 'new-model', label: 'New model' }]
|
||||
})!,
|
||||
'cli'
|
||||
)
|
||||
expect(notices).toHaveBeenCalledTimes(1)
|
||||
@@ -228,3 +237,17 @@ it('reuses a held CLI answer on reopen until account invalidation', async () =>
|
||||
expect(mocks.discover).toHaveBeenCalledTimes(2)
|
||||
stopReopened()
|
||||
})
|
||||
|
||||
it('consumes explicit probe provenance even for empty lists and the literal default ID', () => {
|
||||
expect(
|
||||
cliModelCatalogAnswer('antigravity', { ...cliResult, models: [], catalogOrigin: 'probe' })
|
||||
).toMatchObject({ origin: 'probe', models: [] })
|
||||
expect(
|
||||
cliModelCatalogAnswer('antigravity', {
|
||||
...cliResult,
|
||||
catalogOrigin: 'probe',
|
||||
defaultModelId: 'default',
|
||||
models: [{ id: 'default', label: 'Config default' }]
|
||||
})
|
||||
).toMatchObject({ origin: 'probe', models: [{ id: 'default' }] })
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@ export function sourceEntry(
|
||||
catalogRead: 'settled',
|
||||
sourceCatalogs: {
|
||||
cli: {
|
||||
catalog: cliModelCatalogAnswer(cliResult)!,
|
||||
catalog: cliModelCatalogAnswer('antigravity', cliResult)!,
|
||||
coherentCatalog: true,
|
||||
catalogRead: 'settled'
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { getAgentModelProbeSpec } from '../../../../../shared/agent-model-probe-spec'
|
||||
import { isTuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent-config'
|
||||
import { TERMINAL_EXECUTION_CONTEXT_UNRESOLVED } from '../../../../../shared/terminal/effective-terminal-execution-context'
|
||||
import { ModelMenuContextUnresolvedError } from './host-model-menu-catalog'
|
||||
import type { AgentSessionModelCatalogResult } from '../../../../../shared/agent-session/agent-session-wire'
|
||||
@@ -9,16 +11,28 @@ import { discoverRuntimeTerminalModels } from './terminal-model-discovery-client
|
||||
import type { HostModelMenuScope } from './host-model-menu-catalog'
|
||||
|
||||
export function cliModelCatalogAnswer(
|
||||
agent: string,
|
||||
result: RuntimeDiscoverCommitMessageModelsResult
|
||||
): AgentSessionModelCatalogResult | undefined {
|
||||
if (
|
||||
!result.success ||
|
||||
result.catalogOrigin === 'spec' ||
|
||||
(!result.catalogOrigin && !result.models.length) ||
|
||||
result.models.some(({ id, label }) => id === 'default' && label === 'Config default')
|
||||
(!result.catalogOrigin && !result.models.length)
|
||||
) {
|
||||
return undefined
|
||||
}
|
||||
const fallback = isTuiAgent(agent) ? getAgentModelProbeSpec(agent) : undefined
|
||||
if (
|
||||
!result.catalogOrigin &&
|
||||
fallback &&
|
||||
result.defaultModelId === fallback.defaultModelId &&
|
||||
result.models.length === fallback.models.length
|
||||
) {
|
||||
const fallbackIds = new Set(fallback.models.map(({ id }) => id))
|
||||
if (result.models.every(({ id }) => fallbackIds.has(id))) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
return {
|
||||
origin: 'probe',
|
||||
// This transport has no catalog timestamp; identical listings retain identical values.
|
||||
@@ -49,7 +63,7 @@ export function cliModelMenuScope(
|
||||
if (!result.success && result.error === TERMINAL_EXECUTION_CONTEXT_UNRESOLVED) {
|
||||
throw new ModelMenuContextUnresolvedError(result.error)
|
||||
}
|
||||
return cliModelCatalogAnswer(result)
|
||||
return cliModelCatalogAnswer(agent, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user