Skip to content

Conversation

@zastrowm
Copy link
Member

@zastrowm zastrowm commented Sep 25, 2025

Description

Addresses #667 - we haven't seen any huge deficiencies in these and we need to stabilize hooks

As part of this change we renamed the events to clarify naming and reduce verbosity:

  • BeforeToolInvocationEvent -> BeforeToolCallEvent
  • AfterToolInvocationEvent -> AfterToolCallEvent
  • BeforeModelInvocationEvent -> BeforeModelCallEvent
  • AfterModelInvocationEvent -> AfterModelCallEvent

Part of the motivation of the rename is to avoid confusion with BeforeInvocationEvent and BeforeToolInvocation & BeforeModelInvocationEvent, as we've seen folks confusing them quite a bit.

API Bar Raise

The new names need to be API bar-raised.

The existing events that are not changing are as follows:

Event Purpose
AgentInitializedEvent Triggered when an agent has been constructed and finished initialization at the end of Agent.__init__.
BeforeInvocationEvent Triggered at the beginning of a new agent request (__call__, stream_async, or structured_output)
AfterInvocationEvent Triggered at the end of an agent request, regardless of success or failure. Uses reverse callback ordering
MessageAddedEvent Triggered when a message is added to the agent's conversation history

The proposed events that are being renamed:

Event Purpose
BeforeModelInvocationEvent
BeforeModelCallEvent
Triggered before the model is invoked for inference
AfterModelInvocationEvent
AfterModelCallEvent
Triggered after model invocation completes. Uses reverse callback ordering
BeforeToolInvocationEvent
BeforeToolCallEvent
Triggered before a tool is invoked.
AfterToolInvocationEvent
AfterToolCallEvent
Triggered after tool invocation completes. Uses reverse callback ordering

Backwards compatibility

  • These changes are backwards compatible as the experimental events still exist using aliases
    • We can preserve these for a release or two and then remove the experimental events

Related Issues

#667

Documentation PR

TBD

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

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.

Addresses strands-agents#667 - we haven't seen any huge deficiencies in these and we need to stabilize hooks

As part of this change we renamed the events to clarify naming and reduce verbosity:

  - BeforeToolInvocationEvent -> BeforeToolCallEvent
  - AfterToolInvocationEvent -> AfterToolCallEvent
  - BeforeModelInvocationEvent -> BeforeModelCallEvent
  - AfterModelInvocationEvent -> AfterModelCallEvent

Part of the motivation of the rename is to avoid confusion with BeforeInvocationEvent and BeforeToolInvocation & BeforeModelInvocationEvent, as we've seen folks confusing them quite a bit.

These changes are backwards compatible as the experimental events still exist; we can remove those after a release or two
@zastrowm zastrowm marked this pull request as ready for review September 25, 2025 19:23
@zastrowm zastrowm enabled auto-merge (squash) September 26, 2025 15:39
@zastrowm zastrowm merged commit 99cd49b into strands-agents:main Sep 26, 2025
11 of 12 checks passed
zastrowm added a commit to zastrowm/docs that referenced this pull request Sep 26, 2025
In strands-agents/sdk-python/pull/926 we've released these hooks (and done a rename) so update the docs to account for it

Part of strands-agents/sdk-python#667
zastrowm added a commit to strands-agents/docs that referenced this pull request Sep 26, 2025
In strands-agents/sdk-python/pull/926 we've released these hooks (and done a rename) so update the docs to account for it

Part of strands-agents/sdk-python#667

Co-authored-by: Mackenzie Zastrow <[email protected]>
mkmeral pushed a commit to mkmeral/strands-docs that referenced this pull request Oct 1, 2025
In strands-agents/sdk-python/pull/926 we've released these hooks (and done a rename) so update the docs to account for it

Part of strands-agents/sdk-python#667

Co-authored-by: Mackenzie Zastrow <[email protected]>
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.

3 participants