CODY-021: a removed agent is reconciled the moment its turn settles

If the current agent was taken off the bridge's list while its request was
in flight, start-up rightly kept it for that request, but nothing fell back
afterwards: the screen named the default (first in the list) while state,
storage and the conversation were still the removed agent's.

The controller now reconciles inside dispatch, in the same step as any
state change and before anything is drawn: on a resting screen, if the
stored agent is not offered, the stored agent and thread are swapped to the
default's own and the state follows (agent_reconciled). While a request is
in flight nothing changes, so the turn is never moved or repeated. This
also covers an abandoned turn at start.

CODY-022: README scope list no longer says multiple agents are excluded.

Not reviewed, not deployed, not uploaded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-21 16:24:48 -08:00
co-authored by Claude Fable 5.2
parent c8b4fb0310
commit bb3a309427
5 changed files with 114 additions and 3 deletions
+56
View File
@@ -513,6 +513,62 @@ describe('glasses: which agent it reopens on', () => {
expect(snapshot.state.agents.map((a) => a.id)).toEqual(['default', 'cody']);
});
it('CODY-021: removed while her question is in flight: the turn stays hers and settles honestly, then screen, state, storage and routing all move to the default', async () => {
await paired();
await ask('pepper one');
await backToReady();
device.swipeDown(); // Wendy
h.hermes.next({ kind: 'hang' });
controller.askText('wendy, do the thing');
await until('in flight with Wendy', () => phase() === 'thinking' && h.hermes.executions === 2);
const wendyRequest = snapshot.state.requestId!;
await until('request id saved', () => JSON.parse(device.storage.get('hermeven.v1')!).activeRequestId === wendyRequest);
// The owner takes Wendy off the list and restarts the bridge; the page is reopened.
(h.config.agents as unknown[]).splice(1, 1);
await h.restartBridge();
const before = JSON.parse(device.storage.get('hermeven.v1')!);
device.storage.set('hermeven.v1', JSON.stringify({ ...before, bridgeUrl: h.url }));
await relaunch();
// Still her turn while it is unresolved: re-attached by id, not moved, not repeated.
expect(snapshot.state.requestId ?? wendyRequest).toBe(wendyRequest);
await until('her turn settled', () => phase() === 'error');
expect(snapshot.state.error?.code).toBe('outcome_unknown');
expect(h.hermes.executedBy).toEqual([null, 'wendy']);
// The moment it settled, everything agrees on the default agent.
expect(snapshot.state.agentId).toBe('default');
await until('saved', () => JSON.parse(device.storage.get('hermeven.v1')!).agentId === 'default');
await backToReady();
expect(device.frame.body).toBe('Pepper\n\nReady.');
expect(snapshot.state.agentId).toBe('default');
// The next question goes to the default agent, in the DEFAULT agent's own conversation.
await ask('pepper two');
expect(device.frame.body).toContain('turn=2');
expect(device.frame.body).toContain('pepper one');
expect(h.hermes.executedBy).toEqual([null, 'wendy', null]);
const posts = h.hermes.requests.filter((r) => r.method === 'POST' && r.path === '/v1/runs');
expect(posts.filter((p) => p.profile === 'wendy').length).toBe(1);
expect(snapshot.state.conversationId).toBe(JSON.parse(device.storage.get('hermeven.v1')!).conversationId);
});
it('CODY-021: the same when the question is asked straight from the removed agent\'s result screen, without going back to Ready', async () => {
await paired();
device.swipeDown(); // Wendy
h.hermes.next({ kind: 'hang' });
controller.askText('wendy, do the thing');
await until('in flight with Wendy', () => phase() === 'thinking' && h.hermes.executions === 1);
await until('request id saved', () => typeof JSON.parse(device.storage.get('hermeven.v1')!).activeRequestId === 'string');
(h.config.agents as unknown[]).splice(1, 1);
await h.restartBridge();
const before = JSON.parse(device.storage.get('hermeven.v1')!);
device.storage.set('hermeven.v1', JSON.stringify({ ...before, bridgeUrl: h.url }));
await relaunch();
await until('her turn settled', () => phase() === 'error');
await ask('straight on'); // from the error screen
expect(h.hermes.executedBy).toEqual(['wendy', null]);
expect(device.frame.body).toContain('turn=1');
expect(sent.filter((s) => s.path === '/v1/conversations').map((c) => JSON.parse(c.body).agent_id)).toEqual(['wendy', 'default']);
});
it('the bridge cannot be reached for the list at start: the last known list is used', async () => {
await paired();
device.swipeDown();