pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/strands-agents/sdk-typescript/pull/619

al-a469e846088cc1bf.css" /> feat: implement Plugin system to replace HookProvider by zastrowm · Pull Request #619 · strands-agents/sdk-typescript · GitHub
Skip to content

feat: implement Plugin system to replace HookProvider#619

Open
zastrowm wants to merge 2 commits intostrands-agents:mainfrom
zastrowm:agent-tasks/42
Open

feat: implement Plugin system to replace HookProvider#619
zastrowm wants to merge 2 commits intostrands-agents:mainfrom
zastrowm:agent-tasks/42

Conversation

@zastrowm
Copy link
Member

@zastrowm zastrowm commented Mar 9, 2026

Motivation

The Python SDK recently implemented Plugins as a replacement for HookProvider. Given that TypeScript hasn't shipped yet, we can implement Plugins without backward compatibility concerns around HookProvider.

Plugins provide a more structured approach to extending agent functionality with a required unique name for identification, logging, and duplicate prevention. The initAgent(agent) method is where plugins call agent.addHook() to register callbacks, and getTools() enables auto-registering tools with the agent.

Resolves #42

Public API Changes

AgentConfig now accepts plugins: Plugin[] instead of hooks: HookProvider[]:

// Before
const agent = new Agent({
  model,
  hooks: [myHookProvider],
})

// After
const agent = new Agent({
  model,
  plugins: [myPlugin],
})

Creating plugins follows a class-based pattern matching the Python SDK:

class LoggingPlugin extends Plugin {
  get name(): string {
    return 'logging-plugin'
  }

  override initAgent(agent: AgentData): void {
    agent.addHook(BeforeInvocationEvent, (event) => {
      console.log('Agent invocation started')
    })
  }
}

Runtime hook registration is now done via agent.addHook(), which returns a cleanup function:

const agent = new Agent({ model })

const cleanup = agent.addHook(BeforeInvocationEvent, (event) => {
  console.log('Before invocation')
})

Plugins can provide tools via getTools(), which are auto-registered during plugin initialization:

class MyToolPlugin extends Plugin {
  get name(): string {
    return 'my-tool-plugin'
  }

  override getTools(): Tool[] {
    return [myTool]
  }
}

The same pattern applies to multi-agent orchestrators via MultiAgentPlugin. SwarmOptions now accepts plugins: MultiAgentPlugin[] instead of hooks: HookProvider[], and plugins register callbacks via initMultiAgent(orchestrator):

class LoggingPlugin extends MultiAgentPlugin {
  get name(): string {
    return 'logging-plugin'
  }

  override initMultiAgent(orchestrator: MultiAgentBase): void {
    orchestrator.addHook(BeforeNodeCallEvent, (event) => {
      console.log(`Node ${event.nodeId} starting`)
    })
  }
}

const swarm = new Swarm({
  nodes: [agentA, agentB],
  start: 'agentA',
  plugins: [new LoggingPlugin()],
})

HookProvider is no longer exported. agent.hooks and swarm.hooks are now private — use agent.addHook() / swarm.addHook() for runtime hook registration. PluginRegistry and MultiAgentPluginRegistry are internal. Strands-vended plugin names are prefixed with strands: (e.g., strands:sliding-window-conversation-manager).

Documentation PR

Will update after we get some iterations/review here

@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Mar 9, 2026
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Mar 9, 2026
@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Mar 9, 2026
github-actions[bot]

This comment was marked as duplicate.

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Mar 9, 2026
@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Mar 10, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: Request Changes

Excellent progress! The API has been refined significantly and addresses the previous naming feedback.

Review Summary

Improvements in this iteration:

  • ✅ Renamed initPlugininitAgent (aligns with Python SDK's init_agent)
  • ✅ Simplified API by removing PluginAgent interface (plugins receive AgentData directly)
  • ✅ Extended AgentData interface with toolRegistry and addHook
  • ✅ Added MultiAgentPlugin for orchestrator extensibility
  • ✅ All 1,261 tests passing

Design improvements:

  • Base Plugin.initAgent() auto-registers tools from getTools() - clean pattern
  • AgentData interface provides exactly what plugins need

Blocking Issue: The PR description is still missing a "Documentation PR" section. Please add either:

  1. A link to a documentation PR at https://github.com/strands-agents/docs/pull/..., OR
  2. A justification explaining why documentation updates are not required (e.g., "Documentation not required - TypeScript SDK not yet publicly released")

The implementation is solid and ready to merge once the documentation requirement is addressed!

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Mar 10, 2026
@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Mar 10, 2026
github-actions[bot]

This comment was marked as duplicate.

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Mar 10, 2026
@strands-agents strands-agents deleted a comment from github-actions bot Mar 10, 2026
@zastrowm zastrowm marked this pull request as ready for review March 10, 2026 19:05
@github-actions github-actions bot added strands-running <strands-managed> Whether or not an agent is currently running and removed strands-running <strands-managed> Whether or not an agent is currently running labels Mar 10, 2026
*
* For strands-vended plugins, names should be prefixed with `strands:`.
*/
abstract get name(): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this is a function and not a variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only way to make it abstract; because this is a class, that's the only way to enforce that it's required

/**
* The tool registry for registering tools with the agent.
*/
readonly toolRegistry: ToolRegistry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally curious about what belongs on AgentData? Does system prompt or model belong here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that is our "generic" agent; in my mind that's anything that would be common between Agent and BiDiAgent;

model would not be included for that reason

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up until now I've been conservative and only adding things to AgentData when we're using it - so that if/when we get BiDi agent we don't have any breaking changes

# Conflicts:
#	src/index.ts
#	src/session/__tests__/session-manager.test.ts
#	src/session/session-manager.ts
@github-actions github-actions bot added strands-running <strands-managed> Whether or not an agent is currently running and removed strands-running <strands-managed> Whether or not an agent is currently running labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy