fix(persistence): preserve subagent session origin

This commit is contained in:
imccyu
2026-08-01 09:41:52 +08:00
committed by Tianyi Cui
parent 9d77a50c23
commit d950150cdc
30 changed files with 53 additions and 36 deletions

View File

@@ -276,7 +276,12 @@ export function runCoordinatorContract(name: string, makeFixture: () => Promise<
let session!: Session
const sessionFiber = await ctx.plugin(Object.assign((inner: Context) => {
session = inner.sessions.create(SessionId('delegated-child'), {
meta: { cwd: WORK, parentSession: SessionId('root'), delegationDepth: 2 },
meta: {
cwd: WORK,
parentSession: SessionId('root'),
origin: 'subagent',
delegationDepth: 2,
},
})
}, { inject: ['sessions'] }))
send(session, oneTurnLog())
@@ -285,6 +290,7 @@ export function runCoordinatorContract(name: string, makeFixture: () => Promise<
const loaded = await ctx.sessionPersistence.load(SessionId('delegated-child'))
expect(loaded.meta.delegationDepth).toBe(2)
expect(loaded.meta.origin).toBe('subagent')
} finally {
await fiber.dispose()
await fix.cleanup()