You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: surface parentAgent identity in plugin hook input #15403
I have verified this feature I'm about to request hasn't been suggested before.
When agent A spawns agent B via the task tool, the session layer already tracks the relationship — Session.create() sets parentID: ctx.sessionID in task.ts. But this parent identity never reaches the plugin hooks.
Plugins using tool.execute.before, tool.execute.after, or shell.env can see agent (the current agent) but have no way to know who delegated the work. This blocks any plugin doing delegation-aware policy, audit trails, or permission scoping.
The data is already there in task.ts — ctx.agent is the parent, agent.name is the child. It just needs to be passed through:
// task.ts — the relationship already existsconstsession=awaitSession.create({parentID: ctx.sessionID,// ← session knows its parent
...
})awaitSessionPrompt.prompt({agent: agent.name,// ← child agent// parentAgent: ctx.agent ← missing, this is all that's needed})
Proposal: add an optional parentAgent field to the three hook inputs:
// top-level agent{agent: "coder"}// subagent spawned by coder{agent: "scout",parentAgent: "coder"}
Optional field, fully backwards compatible — no existing plugin breaks. Related to #6527, #12566.
I ran into this writing a plugin that needs to know whether a request comes from a subagent or a primary agent. Without that info in the hook input, the only workaround is parsing agent .md frontmatter at startup to build a name→mode map — fragile and misses built-in agents.
parentAgent in the hook input would fix it cleanly. If it's set, it's a subagent. Simple.
I ran into this writing a plugin that needs to know whether a request comes from a subagent or a primary agent. Without that info in the hook input, the only workaround is parsing agent .md frontmatter at startup to build a name→mode map — fragile and misses built-in agents.
parentAgent in the hook input would fix it cleanly. If it's set, it's a subagent. Simple.
Yup, exactly. Thats how I discovered it too and it ended up being a blocker for a plugin I want to share. Without parentAgent in the hook input, I had to reach for a pretty messy workaround instead of handling it cleanly at runtime
Activity
bnema commentedon Apr 1, 2026
I ran into this writing a plugin that needs to know whether a request comes from a subagent or a primary agent. Without that info in the hook input, the only workaround is parsing agent
.mdfrontmatter at startup to build a name→mode map — fragile and misses built-in agents.parentAgentin the hook input would fix it cleanly. If it's set, it's a subagent. Simple.ArmirKS commentedon Apr 10, 2026
Yup, exactly. Thats how I discovered it too and it ended up being a blocker for a plugin I want to share. Without
parentAgentin the hook input, I had to reach for a pretty messy workaround instead of handling it cleanly at runtimegithub-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
fix(hooks): resolve sessionID for agents to support main thread recog…