Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(calibration): resolve the voice-gate judge model through the key-aware tier (#5165)
garrytanc5b3f01e1e5e
diff --git a/src/core/calibration/voice-gate.ts b/src/core/calibration/voice-gate.tsindex d9dd38bbab..c1d588da57 100644--- a/src/core/calibration/voice-gate.ts+++ b/src/core/calibration/voice-gate.ts@@ -27,7 +27,7 @@import { chat as gatewayChat } from '../ai/gateway.ts';import type { VoiceGateMode } from './templates.ts';-import { TIER_DEFAULTS } from '../model-config.ts';+import { resolveTierDefault } from '../model-config.ts';/*** Verdict the Haiku judge returns for a candidate string. Pass-through@@ -160,7 +160,9 @@ export async function defaultJudge(input: {.replace('{CANDIDATE}', input.candidate);const result = await gatewayChat({messages: [{ role: 'user', content: prompt }],- model: TIER_DEFAULTS.utility,+ // #5165: the key-aware utility tier, not the Anthropic floor, so an+ // install without Anthropic credit judges with a provider it has.+ model: resolveTierDefault('utility'),maxTokens: 100,});return parseJudgeOutput(result.text);diff --git a/test/voice-gate-judge-tier.test.ts b/test/voice-gate-judge-tier.test.tsnew file mode 100644index 0000000000..57e04acd7b--- /dev/null+++ b/test/voice-gate-judge-tier.test.ts@@ -0,0 +1,35 @@+/**+ * #5165 (duplicates #5303, #5357): the voice-gate judge hardcoded the+ * Anthropic utility default, so installs without Anthropic credit failed every+ * gate. It now resolves the utility tier through the key-aware resolver.+ */++import { describe, test, expect, afterEach } from 'bun:test';++import { defaultJudge } from '../src/core/calibration/voice-gate.ts';+import { configureGateway, resetGateway, __setChatTransportForTests, type ChatOpts } from '../src/core/ai/gateway.ts';+import { resolveTierDefault, TIER_DEFAULTS } from '../src/core/model-config.ts';+import { withEnv } from './helpers/with-env.ts';++afterEach(() => {+ resetGateway();+ __setChatTransportForTests(null);+});++describe('#5165 voice-gate judge model', () => {+ test('an OpenAI-only install judges with the OpenAI utility model', async () => {+ await withEnv({ OPENAI_API_KEY: 'sk-fake', ANTHROPIC_API_KEY: undefined }, async () => {+ configureGateway({ env: { OPENAI_API_KEY: 'sk-fake' } });+ let model: string | undefined;+ __setChatTransportForTests(async (opts: ChatOpts) => {+ model = opts.model;+ return { text: '{"verdict":"conversational","reason":"ok"}', blocks: [], stopReason: 'end', usage: { input_tokens: 1, output_tokens: 1, cache_read_tokens: 0, cache_creation_tokens: 0 }, model: opts.model ?? '', providerId: 'openai' } as never;+ });+ const verdict = await defaultJudge({ candidate: 'hey, quick note', mode: 'nudge' as never, rubric: 'be casual' });+ expect(verdict.verdict).toBe('conversational');+ const expected = resolveTierDefault('utility', { OPENAI_API_KEY: 'sk-fake' });+ expect(expected).not.toBe(TIER_DEFAULTS.utility);+ expect(model).toBe(expected);+ });+ });+});