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
Copy Markdown

@ArmirKS ArmirKS commented Feb 27, 2026

Issue for this PR

Fixes #15403

Type of change

  • New feature

What does this PR do?

This adds parentAgent to the plugin hook inputs that need subagent context.
The main fix here is making sure that value actually survives the full prompt flow, so it reaches tool.execute.before, tool.execute.after, shell.env, chat.params, and chat.headers consistently.
Everything is additive, so existing plugins keep working.

How did you verify your code works?

  • added coverage for the new prompt/message shapes
  • ran bun test test/plugin/parent-agent.test.ts
  • ran bun typecheck in packages/plugin
  • ran bun typecheck in packages/opencode

Checklist

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

@bbo76
Copy link
Copy Markdown

bbo76 commented Mar 31, 2026

any news for this ?

@bnema
Copy link
Copy Markdown
Contributor

bnema commented Apr 2, 2026

This is great, one gap though: chat.headers and chat.params in llm.ts don't get parentAgent. The PR adds it to tool.execute.* and shell.env, but the LLM hook inputs still only have agent (the name string).

Adding it would be a small change in llm.ts. parentAgent just needs to flow from StreamInput into the Plugin.trigger("chat.headers", ...) and Plugin.trigger("chat.params", ...) calls. That would let plugins adjust headers or model params based on whether the request comes from a subagent.

@tassiocaique
Copy link
Copy Markdown

any new for this?

ArmirKS added 3 commits April 10, 2026 22:27
Ensures parentAgent is persisted on user messages, included in
Tool.Context during tool resolution, and passed through the main
loop's resolveTools call.
@ArmirKS ArmirKS force-pushed the feat/parentAgent-hook-input branch from 50ae844 to 6bf3b18 Compare April 10, 2026 21:33
@ArmirKS
Copy link
Copy Markdown
Author

ArmirKS commented Apr 10, 2026

Thanks @bnema I fixed the llm.ts gap you called out. parentAgent now reaches both chat.params and chat.headers and is carried through subagent flows consistently

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

4 participants