test(subagent): include directory context in settlement fixture

This commit is contained in:
Tianyi Cui committed 2026-10-06 01:27:55 +08:00
1 parent d5edd3294b
commit 1d606f09ea
1 file changed
+14 -5
@@ -41,7 +41,7 @@ it('continues the parent through default Messages after a reasoning-bearing cont
resolveUserId: () => '00000000-0000-4000-8000-000000000001' as AnonymousUserId,
prepareExtensions: () => Promise.resolve({ fields: {}, accept: () => Promise.resolve() }),
})
await mountAgentLoopTestDependencies(ctx)
await mountAgentLoopTestDependencies(ctx, { workingDirectory: true })
await ctx.plugin(JsonlSessionPersistence, { root })
await ctx.plugin(AgentLoop, { agents: [] })
await ctx.plugin(SubagentRuntime)
@@ -75,12 +75,21 @@ it('continues the parent through default Messages after a reasoning-bearing cont
expect(requests).toHaveLength(2)
expect(requests.map(request => request.path)).toEqual(['/anthropic/v1/messages', '/anthropic/v1/messages'])
const notice = parent.session.deriveMessages().find(message => message.source.kind === 'subagent-settled')
expect(notice?.content).toEqual([
const closingContent = [
{ type: 'text', text: `Background subagent ${started.childId} finished and will do no further work unless you send it more.` },
{ type: 'text', text: 'Its closing message:' },
{ type: 'text', text: 'child answer' },
])
expect(requests[1]?.body).toMatchObject({ messages: [{ role: 'user', content: notice?.content }] })
]
expect(notice?.content).toEqual(closingContent)
const noticeWithContext = [
...closingContent,
{
type: 'text',
text: 'Current runtime context. This snapshot supersedes earlier runtime-context snapshots.\n\n'
+ `Current working directory: ${JSON.stringify(process.cwd())}.`,
},
]
expect(requests[1]?.body).toMatchObject({ messages: [{ role: 'user', content: noticeWithContext }] })
parent.followup(createUserMessage({ source: { kind: 'user' }, content: [{ type: 'text', text: 'continue' }] }))
await parent.whenIdle()
@@ -88,7 +97,7 @@ it('continues the parent through default Messages after a reasoning-bearing cont
.toMatchObject([{ data: { reason: { kind: 'completed' } } }, { data: { reason: { kind: 'completed' } } }])
expect(requests).toHaveLength(3)
expect(requests[2]?.body).toMatchObject({ messages: [
{ role: 'user', content: notice?.content },
{ role: 'user', content: noticeWithContext },
{ role: 'assistant', content: [{ type: 'text', text: 'parent answer' }] },
{ role: 'user', content: [{ type: 'text', text: 'continue' }] },
] })