Skip to content

feat(plugin): surface agent and parentAgent in plugin hook input#15412

Open
ArmirKS wants to merge 4 commits intoanomalyco:devfrom
ArmirKS:feat/parentAgent-hook-input
Open

feat(plugin): surface agent and parentAgent in plugin hook input#15412
ArmirKS wants to merge 4 commits intoanomalyco:devfrom
ArmirKS:feat/parentAgent-hook-input

Conversation

@ArmirKS
Copy link

@ArmirKS ArmirKS commented Feb 27, 2026

Issue for this PR

Fixes #15403

Type of change

  • New feature

What does this PR do?

Plugin hooks (tool.execute.before, tool.execute.after, shell.env) have no visibility into which agent made a tool call or who delegated it. The session layer already tracks parent relationships (Session.create sets parentID in task.ts), but this never reaches plugins.

This adds optional agent and parentAgent fields to the three hook inputs. When agent A spawns agent B via the task tool, hooks receive { agent: "B", parentAgent: "A" }. Top-level agents have parentAgent undefined.

The key line is in task.tsparentAgent: ctx.agent. Everything else is threading it through existing Plugin.trigger call sites.

Same pattern as #13662 which added sessionID and callID to shell.env.

How did you verify your code works?

  • 5 schema-level tests validating PromptInput, ShellInput, and UserMessage accept and preserve parentAgent (and remain backwards compatible without it)
  • Typecheck clean across all 18 packages via bun turbo typecheck

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Adds agent and parentAgent to tool.execute.before, tool.execute.after,
and shell.env hook input. When agent A spawns agent B via the task tool,
hooks receive { agent: 'B', parentAgent: 'A' }. Top-level agents have
parentAgent undefined.

Both fields are optional — no existing plugin breaks.

Fixes anomalyco#15403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: surface parentAgent identity in plugin hook input

1 participant