Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: pre-landing review fixes
garrytane246516b43b7
diff --git a/src/core/interop-notices.ts b/src/core/interop-notices.tsindex 9d3916f029..15e3f969f8 100644--- a/src/core/interop-notices.ts+++ b/src/core/interop-notices.ts@@ -303,8 +303,8 @@ export function modelOverrideIgnoredNotice(reason: 'not_allowed' | 'unusable'):kind: 'info',dedupe_key: reason,why: reason === 'not_allowed'- ? 'This brain runs think on its own configured model for remote callers, so the requested model was not used; the answer came from the host think model (modelUsed names it). Omit model, or ask the brain owner to allow it on the brain host.'- : 'The requested model is allowed for remote callers on this brain but cannot run there right now, so the host think model answered instead (modelUsed names it).',+ ? 'This brain runs think on its own configured model for remote callers, so the requested model was not used; think ran on the host think model instead (modelUsed names it). Omit model, or ask the brain owner to allow it on the brain host.'+ : 'The requested model is allowed for remote callers on this brain but cannot run there right now, so it was not used; think ran on the host think model instead (modelUsed names it).',...(reason === 'not_allowed' ? {fix: {argv: ['gbrain', 'config', 'set', 'think.remote_models', '<models>'],diff --git a/src/core/ops/takes.ts b/src/core/ops/takes.tsindex 3fcbe20fbf..96e21d07b7 100644--- a/src/core/ops/takes.ts+++ b/src/core/ops/takes.ts@@ -304,7 +304,7 @@ export const THINK_REMOTE_MODELS_KEY = 'think.remote_models';*/async function remoteThinkModel(engine: OperationContext['engine'], requested: string | undefined): Promise<{ model?: string; ignored?: 'not_allowed' | 'unusable' }> {if (!requested) return {};- const [{ resolveModel }, { normalizeModelId }, { probeChatModel }] = await Promise.all([+ const [{ resolveModel }, { normalizeModelId }, { probeChatModel, isAvailable }] = await Promise.all([import('../model-config.ts'), import('../model-id.ts'), import('../ai/gateway.ts'),]);const resolve = async (cliFlag?: string) => normalizeModelId(await resolveModel(engine, { cliFlag, configKey: 'models.think', tier: 'deep', fallback: 'opus' }));@@ -312,7 +312,7 @@ async function remoteThinkModel(engine: OperationContext['engine'], requested: sif (wanted === host) return {};const allowed = await Promise.all((listed ?? '').split(',').map(m => m.trim()).filter(Boolean).map(m => resolve(m)));if (!allowed.includes(wanted)) return { ignored: 'not_allowed' };- return probeChatModel(wanted).ok ? { model: wanted } : { ignored: 'unusable' };+ return probeChatModel(wanted).ok && isAvailable('chat', wanted) ? { model: wanted } : { ignored: 'unusable' };}const think: Operation = {diff --git a/test/think-remote-model.test.ts b/test/think-remote-model.test.tsindex 22b8b6b831..31dbb521c0 100644--- a/test/think-remote-model.test.ts+++ b/test/think-remote-model.test.ts@@ -90,6 +90,17 @@ for (const kind of testBackends()) {expect(called).toEqual(['gpt-6.1-sol']);expect(r.body.warnings).toContain('MODEL_OVERRIDE_IGNORED:unusable');expect(r.notices.find(n => n.code === 'model_override_ignored')?.why).toContain('cannot run');+ expect(r.notices.find(n => n.code === 'model_override_ignored')?.why).not.toContain('answered');+ });++ test('a listed model whose provider key the host lacks answers on the host model, not with a key error', async () => {+ keyed();+ await engine.setConfig('think.remote_models', 'deepseek:deepseek-chat');+ const r = await remoteThink({ model: 'deepseek:deepseek-chat' });+ expect(r.isError).toBe(false);+ expect(called).toEqual(['gpt-6.1-sol']);+ expect(r.body.synthesis_status).toBe('ok');+ expect(r.body.warnings).toContain('MODEL_OVERRIDE_IGNORED:unusable');});test('a model param naming the host think model runs it with no notice', async () => {