The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): log unexpected agent model update failures (#1637)
0xken1505778dc93666
diff --git a/cli/src/core/agents/update.spec.ts b/cli/src/core/agents/update.spec.tsindex a23302542..65ba726f7 100644--- a/cli/src/core/agents/update.spec.ts+++ b/cli/src/core/agents/update.spec.ts@@ -75,6 +75,22 @@ describe('a model and effort', () => {expect(await refused({ onRuntimeProfileUpdate: async () => { throw new RuntimeProfileControlError('BUSY') } }, 'runtime-v1:x')).toEqual([['reply', { error: 'BUSY' }]])expect(await refused({ onRuntimeProfileUpdate: async () => { throw new Error('pane gone') } }, 'runtime-v1:x')).toEqual([['reply', { error: 'INTERNAL' }]])})++ it('logs the name and message of an unexpected profile failure without request contents', async () => {+ const error = vi.spyOn(console, 'error').mockImplementation(() => {})+ const { heard, ask } = setup({ onRuntimeProfileUpdate: async () => { throw new TypeError('engine state disappeared') } })+ await ask({ agentId: 'a1', selectedModel: 'runtime-v1:s1:claude:private-model@high' })+ expect(heard).toEqual([['reply', { error: 'INTERNAL' }]])+ expect(error).toHaveBeenCalledExactlyOnceWith('[agent_update] model update failed: TypeError: engine state disappeared')+ })++ it('gives a non-Error exception a safe description', async () => {+ const error = vi.spyOn(console, 'error').mockImplementation(() => {})+ const { heard, ask } = setup({ onRuntimeProfileUpdate: async () => { throw null } })+ await ask({ agentId: 'a1', selectedModel: 'runtime-v1:s1:claude:private-model@high' })+ expect(heard).toEqual([['reply', { error: 'INTERNAL' }]])+ expect(error).toHaveBeenCalledExactlyOnceWith('[agent_update] model update failed: UnknownError: non-Error exception')+ })})describe('a rename', () => {diff --git a/cli/src/core/agents/update.ts b/cli/src/core/agents/update.tsindex a5b16b449..ea98c39eb 100644--- a/cli/src/core/agents/update.ts+++ b/cli/src/core/agents/update.ts@@ -62,6 +62,11 @@ export function createAgentUpdate({try {await onRuntimeProfileUpdate(projectId, payload.selectedModel)} catch (error) {+ if (!(error instanceof RuntimeProfileControlError)) {+ const name = error instanceof Error ? preview(error.name, 80) : 'UnknownError'+ const message = error instanceof Error ? preview(error.message, 200) : 'non-Error exception'+ console.error(`[agent_update] model update failed: ${name}: ${message}`)+ }const code: RuntimeProfileErrorCode | 'INTERNAL' = error instanceof RuntimeProfileControlError ? error.code : 'INTERNAL'reply({ error: code })return