fix(core): identify spawned subagents (#38189)

This commit is contained in:
Dax 2026-07-21 16:54:01 -04:00 committed by GitHub
commit 1ea9137c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -185,7 +185,11 @@ export const Plugin = {
const run = Effect.gen(function* () {
// The child session owns its agent/model (set at create); prompt only admits input.
yield* runtime.session.prompt({ sessionID: child.id, text: input.prompt, resume: false })
yield* runtime.session.prompt({
sessionID: child.id,
text: ["You are a subagent spawned by another session.", input.prompt].join("\n"),
resume: false,
})
yield* runtime.session.resume(child.id)
return yield* latestAssistantText(child.id)
}).pipe(Effect.onInterrupt(() => runtime.session.interrupt(child.id)))

View file

@ -273,6 +273,9 @@ describe("SubagentTool", () => {
agent: "reviewer",
model: childModel,
})
expect((yield* sessions.pending(child.id)).find((message) => message.type === "user")?.data.text).toBe(
"You are a subagent spawned by another session.\nreview this",
)
const fallback = yield* settleTool(registry, {
sessionID: parent.id,