From 1d606f09ea8fc57d703cefdc367b92d90e4488ce Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:16:34 +0800 Subject: [PATCH] test(subagent): include directory context in settlement fixture --- .../continuation-messages-adapter.spec.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/subagent/subagent/tests/continuation-messages-adapter.spec.ts b/packages/subagent/subagent/tests/continuation-messages-adapter.spec.ts index cd26a3153e..3dabbe6b0b 100644 --- a/packages/subagent/subagent/tests/continuation-messages-adapter.spec.ts +++ b/packages/subagent/subagent/tests/continuation-messages-adapter.spec.ts @@ -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' }] }, ] })