The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): bot profile writes take the pool's foreground slot
teknium181279c527954
diff --git a/apps/desktop/src/plugins/hermes-bots/data.bot-meta.test.ts b/apps/desktop/src/plugins/hermes-bots/data.bot-meta.test.tsindex 23d080e801e..d4a6eac1123 100644--- a/apps/desktop/src/plugins/hermes-bots/data.bot-meta.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/data.bot-meta.test.ts@@ -114,6 +114,37 @@ describe('a save reports what the SERVER did, not just what the screen shows', (})})+describe('a save for a bot on the pooled local backend', () => {+ it('is admitted while warm bot backends hold every background slot', async () => {+ // Main's pool admission, reduced: cap 3 with one slot reserved for+ // foreground dials. Two warm bots hold both background slots and beta's+ // backend is cold, so a dial without an explicit priority (background,+ // main's default) waits out its slot deadline and fails.+ hostMock.requestProfile.mockImplementation(+ async (+ _route: unknown,+ method: string,+ _params: unknown,+ _timeoutMs?: number,+ options?: { spawnPriority?: 'background' | 'foreground' }+ ) => {+ if ((options?.spawnPriority ?? 'background') === 'background') {+ throw new Error('Local backend start for "beta" timed out while waiting for a free slot. (background)')+ }++ return method === 'profiles.configure' ? { applied: { ui_meta: true } } : {}+ }+ )++ const beta = { connectionId: 'local', connectionKind: 'local', name: 'beta', sourceScoped: true } as RosterRow++ await expect(saveBotMeta(beta, { sectionId: 'sec-1', sectionName: 'Clients' })).resolves.toEqual({+ serverOutcome: 'persisted',+ serverPersisted: true+ })+ })+})+describe('avatar asset sync fires only on a real change', () => {// Edit Profile always sends the image key, changed or not. Firing// set_asset for every patch re-uploaded the full data URL — and a no-opdiff --git a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx b/apps/desktop/src/plugins/hermes-bots/profile-config.tsxindex cd7b31a8681..3be45996daa 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx+++ b/apps/desktop/src/plugins/hermes-bots/profile-config.tsx@@ -141,15 +141,14 @@ export function AdvancedProfileConfig({ bot, state, setState }: AdvancedProfileCif (!loaded) {setLoaded(true)+ // The user just opened this editor: a cold backend takes the pool's+ // reserved slot instead of queuing behind warm roster backends.+ const opened = { spawnPriority: 'foreground' } as constPromise.all([- requestForBot(bot, 'profiles.describe', {- name: bot.name- }) as Promise<ProfileDescribeResponse>,- (- requestForBot(bot, 'mcp.catalog', {- profile: bot.name- }) as Promise<McpCatalogResponse>- ).catch(() => null)+ requestForBot(bot, 'profiles.describe', { name: bot.name }, opened) as Promise<ProfileDescribeResponse>,+ (requestForBot(bot, 'mcp.catalog', { profile: bot.name }, opened) as Promise<McpCatalogResponse>).catch(+ () => null+ )]).then(([res, cat]) => {const configured = res.mcp_servers || []diff --git a/apps/desktop/src/plugins/hermes-bots/routing.test.ts b/apps/desktop/src/plugins/hermes-bots/routing.test.tsindex 476f9e66d7b..6e986fcbb8d 100644--- a/apps/desktop/src/plugins/hermes-bots/routing.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/routing.test.ts@@ -256,10 +256,13 @@ describe('requestForBot rides the bot’s own source', () => {soul: '# hi'})- expect(hostMock.requestProfile).toHaveBeenCalledWith(MOXIE_ROUTE, 'profiles.configure', {- name: 'default',- soul: '# hi'- })+ expect(hostMock.requestProfile).toHaveBeenCalledWith(+ MOXIE_ROUTE,+ 'profiles.configure',+ { name: 'default', soul: '# hi' },+ undefined,+ { spawnPriority: 'foreground' }+ )})it('fails closed rather than falling back to the ambient request', async () => {diff --git a/apps/desktop/src/plugins/hermes-bots/routing.ts b/apps/desktop/src/plugins/hermes-bots/routing.tsindex dd431b6c1c1..ef4053f65cb 100644--- a/apps/desktop/src/plugins/hermes-bots/routing.ts+++ b/apps/desktop/src/plugins/hermes-bots/routing.ts@@ -207,6 +207,13 @@ export interface BotRequestOptions {timeoutMs?: number}+/** Writes to a bot's own profile only ever come from a user action (a save,+ * a section move, an avatar change, a duplicate). The pool reserves a slot+ * for foreground dials only, so a write left at the background default+ * queues behind warm bot backends, times out after 30 s, then backs off —+ * the write is lost. They dial foreground unless the caller says otherwise. */+const PROFILE_WRITE_METHODS = new Set(['profiles.configure', 'profiles.create', 'profiles.set_asset'])+export async function requestForBot<T = unknown>(bot: Partial<RosterRow> | null | undefined,method: string,@@ -223,10 +230,13 @@ export async function requestForBot<T = unknown>(try {const routedParams = scopedBotParams(route, method, params)+ const spawnPriority =+ options?.spawnPriority ?? (PROFILE_WRITE_METHODS.has(method) ? ('foreground' as const) : undefined)+// Keep the three-argument shape when no options were given so older// desktop shells (and the arity-pinning tests) see the same call.- return await (options?.spawnPriority- ? host.requestProfile(route, method, routedParams, options.timeoutMs, { spawnPriority: options.spawnPriority })+ return await (spawnPriority+ ? host.requestProfile(route, method, routedParams, options?.timeoutMs, { spawnPriority }): options?.timeoutMs === undefined? host.requestProfile(route, method, routedParams): host.requestProfile(route, method, routedParams, options.timeoutMs))diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex 1723498d231..96452e7ebf8 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -539,7 +539,7 @@ host.logs(...) // tail an app log filehost.status() // one-shot system status snapshothost.restartGateway() // restart the backend gatewayhost.profileRoutes() // [{ profile, targetProfile, connectionId, mode }]-host.requestProfile<T>(route, method, params?) // registry-routed RPC; no foreground swap+host.requestProfile<T>(route, method, params?, timeoutMs?, { spawnPriority? }) // registry-routed RPC; no foreground swaphost.requestProfile<T>(profile, method, params?) // legacy v1/local overloadhost.request<T>(method, params?) // active-gateway JSON-RPC — the real power```@@ -551,6 +551,13 @@ profile without changing the active chat or gateway. The profile-only overload iretained only for the sole-local/legacy topology; registry-aware plugins should passthe descriptor so two sources exposing the same profile name cannot collide.+A call that may cold-start a pooled profile backend dials at background priority by+default, and background dials never get the slot the pool keeps free for user actions.+When the call IS a user action (a save, a button press, a dialog opening), pass+`host.requestProfile(route, method, params, undefined, { spawnPriority: 'foreground' })`;+otherwise, with the pool full of warm backends, it waits out the 30-second slot timeout+and fails. Keep the background default for polling and roster warming.+`host.openWorkspace(id, { render, title?, minWidth?, onClose? })` docks aplugin-rendered view into the **main workspace zone** — the same center areasession tiles and previews use — as a tab, and reveals it. Re-calling it with