This commit is contained in:
@@ -240,8 +240,13 @@ test('agent CLI exposes production flags and inspect subcommands', async (t) =>
|
||||
t.ok(CLI.includes("sub === 'export'"))
|
||||
t.ok(CLI.includes("sub === 'remember'"))
|
||||
t.ok(CLI.includes("sub === 'recap'"))
|
||||
t.ok(CLI.includes("sub === 'models'"))
|
||||
t.ok(CLI.includes("sub === 'models' && rest[0] === 'models'"))
|
||||
t.ok(CLI.includes('bareAgentApplyLiveModel'))
|
||||
t.ok(TUI.includes('planMode'))
|
||||
t.ok(TUI.includes('modelOverride'))
|
||||
t.ok(TUI.includes('bareAgentHonorExplicitQvacModel'))
|
||||
t.ok(TUI.includes('bareAgentSaveConfig'))
|
||||
t.ok(TUI.includes('extraSystemFile'))
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import test from 'brittle'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import vm from 'node:vm'
|
||||
|
||||
const QVAC_SRC = readFileSync(new URL('../lib/agent/agent-qvac.js', import.meta.url), 'utf8')
|
||||
const MODELS_SRC = readFileSync(
|
||||
new URL('../lib/agent/agent-models.js', import.meta.url),
|
||||
'utf8'
|
||||
)
|
||||
const TUI_SRC = readFileSync(new URL('../lib/agent/agent-tui.js', import.meta.url), 'utf8')
|
||||
|
||||
function load() {
|
||||
const sandbox = { console }
|
||||
vm.createContext(sandbox)
|
||||
vm.runInContext(
|
||||
QVAC_SRC +
|
||||
'\n' +
|
||||
MODELS_SRC +
|
||||
'\n' +
|
||||
TUI_SRC +
|
||||
'\n;this.__exports = { bareAgentHonorExplicitQvacModel, bareAgentApplyLiveModel, bareAgentApplyProviderProfile, bareAgentQvacGetProfile, bareAgentQvacFindChatModel }',
|
||||
sandbox
|
||||
)
|
||||
return sandbox.__exports
|
||||
}
|
||||
|
||||
test('explicit QVAC model survives profile apply (live Discord/CLI switch)', async (t) => {
|
||||
const { bareAgentApplyProviderProfile } = load()
|
||||
const next = bareAgentApplyProviderProfile({
|
||||
backend: 'qvac',
|
||||
qvac_profile: 'recommended',
|
||||
qvac_model: 'QWEN3_8B_INST_Q4_K_M',
|
||||
model: 'QWEN3_8B_INST_Q4_K_M'
|
||||
})
|
||||
t.is(next.qvac_model, 'QWEN3_8B_INST_Q4_K_M')
|
||||
t.is(next.model, 'QWEN3_8B_INST_Q4_K_M')
|
||||
})
|
||||
|
||||
test('empty QVAC model fills from profile', async (t) => {
|
||||
const { bareAgentApplyProviderProfile, bareAgentQvacGetProfile } = load()
|
||||
const next = bareAgentApplyProviderProfile({
|
||||
backend: 'qvac',
|
||||
qvac_profile: 'strong'
|
||||
})
|
||||
t.is(next.qvac_model, bareAgentQvacGetProfile('strong').chatModel)
|
||||
})
|
||||
|
||||
test('apply live model on QVAC sets both keys and profile when catalog-known', async (t) => {
|
||||
const { bareAgentApplyLiveModel } = load()
|
||||
const next = bareAgentApplyLiveModel(
|
||||
{ backend: 'qvac', qvac_profile: 'recommended', qvac_model: 'QWEN3_1_7B_INST_Q4' },
|
||||
'QWEN3_600M_INST_Q4'
|
||||
)
|
||||
t.is(next.qvac_model, 'QWEN3_600M_INST_Q4')
|
||||
t.is(next.model, 'QWEN3_600M_INST_Q4')
|
||||
t.is(next.qvac_profile, 'lite')
|
||||
})
|
||||
|
||||
test('apply live model on REST only changes model', async (t) => {
|
||||
const { bareAgentApplyLiveModel } = load()
|
||||
const next = bareAgentApplyLiveModel(
|
||||
{
|
||||
backend: 'rest',
|
||||
provider: 'groq',
|
||||
rest_api_key: 'gsk',
|
||||
rest_base_url: 'https://api.groq.com/openai/v1',
|
||||
model: 'old'
|
||||
},
|
||||
'llama-3.1-8b-instant'
|
||||
)
|
||||
t.is(next.backend, 'rest')
|
||||
t.is(next.model, 'llama-3.1-8b-instant')
|
||||
t.absent(next.qvac_model)
|
||||
})
|
||||
@@ -56,3 +56,40 @@ test('fetch REST models uses /models and falls back on empty', async (t) => {
|
||||
)
|
||||
t.ok(s.bareAgentRestModelsFallback('groq').some((m) => m.id === 'llama-3.3-70b-versatile'))
|
||||
})
|
||||
|
||||
test('honor explicit QVAC model does not fall back to profile default', async (t) => {
|
||||
const s = load()
|
||||
const next = s.bareAgentHonorExplicitQvacModel(
|
||||
{
|
||||
qvac_profile: 'recommended',
|
||||
qvac_model: 'QWEN3_8B_INST_Q4_K_M',
|
||||
model: 'QWEN3_8B_INST_Q4_K_M'
|
||||
},
|
||||
{ chatModel: 'QWEN3_1_7B_INST_Q4' }
|
||||
)
|
||||
t.is(next.qvac_model, 'QWEN3_8B_INST_Q4_K_M')
|
||||
t.is(next.model, 'QWEN3_8B_INST_Q4_K_M')
|
||||
})
|
||||
|
||||
test('apply live model switches QVAC and REST independently', async (t) => {
|
||||
const s = load()
|
||||
const qvac = s.bareAgentApplyLiveModel(
|
||||
{ backend: 'qvac', qvac_profile: 'recommended', qvac_model: 'QWEN3_1_7B_INST_Q4' },
|
||||
'QWEN3_600M_INST_Q4'
|
||||
)
|
||||
t.is(qvac.qvac_model, 'QWEN3_600M_INST_Q4')
|
||||
t.is(qvac.qvac_profile, 'lite')
|
||||
const rest = s.bareAgentApplyLiveModel(
|
||||
{
|
||||
backend: 'rest',
|
||||
provider: 'groq',
|
||||
rest_api_key: 'gsk',
|
||||
rest_base_url: 'https://api.groq.com/openai/v1',
|
||||
model: 'old'
|
||||
},
|
||||
'llama-3.1-8b-instant'
|
||||
)
|
||||
t.is(rest.backend, 'rest')
|
||||
t.is(rest.model, 'llama-3.1-8b-instant')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user