Skip to content

refactor(agent): convert printer to plugin pattern#689

Open
zastrowm wants to merge 2 commits intostrands-agents:mainfrom
zastrowm:agent_printer
Open

refactor(agent): convert printer to plugin pattern#689
zastrowm wants to merge 2 commits intostrands-agents:mainfrom
zastrowm:agent_printer

Conversation

@zastrowm
Copy link
Member

Description

AgentPrinter was wired directly into the agent loop as a private _printer field, with the agent manually calling _printer?.processEvent(event) on every yielded event. AgentPrinter now implements Plugin and registers its own hook callbacks via initAgent(). The Printer interface has been removed as it was only used internally.

The printer: false option still suppresses it and default behavior is unchanged.

Related Issues

#270

Documentation PR

Internal refactor; no public API changes requiring doc updates.

Type of Change

Refactor

Testing

How have you tested the change?

  • I ran npm run check

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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

Code Review: ✅ Approve

Assessment: Approve

Clean internal refactor that converts AgentPrinter from a directly-wired implementation to the Plugin pattern, improving extensibility and consistency with other SDK components like SlidingWindowConversationManager.

Review Summary
  • Plugin Pattern: Correctly implements Plugin interface with name getter and initAgent() hook registration
  • Backward Compatibility: printer?: boolean config maintained, default behavior unchanged
  • Internal Only: Printer interface removed (was internal-only), AgentPrinter not exported from index.ts
  • Test Quality: Tests updated to verify behavior externally via plugin injection rather than relying on internal _printer field access
  • Code Quality: All checks pass (83 tests, type-check, lint)

Good work on maintaining the same functionality while making the architecture more consistent. 👍

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Mar 18, 2026
@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 18, 2026
@zastrowm zastrowm enabled auto-merge March 18, 2026 21:45
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.

1 participant