Skip to content

[FEATURE]: surface parentAgent identity in plugin hook input #15403

@ArmirKS

Description

@ArmirKS
  • 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.tsctx.agent is the parent, agent.name is the child. It just needs to be passed through:

// task.ts — the relationship already exists
const session = await Session.create({
  parentID: ctx.sessionID,  // ← session knows its parent
  ...
})

await SessionPrompt.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.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions