Skip to content

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

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

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

Conversation

@ArmirKS
Copy link
Copy Markdown

@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

@ArmirKS ArmirKS marked this pull request as ready for review February 27, 2026 23:08
@ArmirKS ArmirKS force-pushed the feat/parentAgent-hook-input branch 2 times, most recently from dfa2ec5 to e2b243b Compare March 11, 2026 00:06
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