fix(agent-presets): re-link recompose through the mount-time binding

The auto-merge kept recompose on the removed open re-link. It now moves
the binding this roster kept from the agent's mount; an agent that never
composed one has nothing to re-link, so the switch is its first bind —
exactly a mount — and once bound only the kept binding can move it.
This commit is contained in:
Yichen Jiang
2026-08-10 11:20:55 +08:00
parent 39982843f6
commit bdcf940eea
2 changed files with 21 additions and 3 deletions

View File

@@ -368,9 +368,19 @@ describe('replacing a composition', () => {
expect(toolNames(ctx, handle.agent)).toEqual(['alpha'])
})
it('leaves an agent that never composed one with nothing to restore', async () => {
it('binds an agent that never composed one as its first mount', async () => {
// No binding exists to re-link, so the switch is the agent's first bind
// — and once bound, only this roster's kept binding can move it again.
const handle = await ctx.agents.create({ sessionId: SessionId('sess-bare') })
await ctx.agentPresets.recompose(handle.agent.ctx, 'standard')
expect(toolNames(ctx, handle.agent)).toEqual(['alpha'])
})
it('leaves an agent that never composed one with nothing to restore', async () => {
const handle = await ctx.agents.create({ sessionId: SessionId('sess-bare-broken') })
await expect(ctx.agentPresets.recompose(handle.agent.ctx, 'broken'))
.rejects.toThrow(/failed to mount/)