Skip to content

Conversation

deepyes02
Copy link
Contributor

Fix(doc): Replaced StartRequestEvent & EndRequestEvent with BeforeInvocationEvent & AfterInvocationEvent respectively in the docstring for api reference documentation

Description

`StartRequestEvent' & 'EndRequestEvent' in the documentation caused some confusion for users. They seem deprecated, and create errors in the code editor when used.

Related Issues

Wrong information appearing in the documentation, causing some confusion, so I fixed it in this update:
https://strandsagents.com/latest/documentation/docs/api-reference/hooks/

image

Corrected version

from strands.hooks import HookProvider, HookRegistry
from strands.hooks.events import BeforeInvocationEvent, AfterInvocationEvent
# from strands_tools.calculator import calculator

class LoggingHooks(HookProvider):
  def register_hooks(self, registry: HookRegistry) -> None:  
    registry.add_callback(BeforeInvocationEvent, self.log_start)
    registry.add_callback(AfterInvocationEvent, self.log_end)
  
  def log_start(self, event: BeforeInvocationEvent):
    print(f"Request started for {event.agent.name}")
  
  def log_end(self, event: AfterInvocationEvent):
    print(f"Request ended for {event.agent.name}")

agent = Agent(hooks=[LoggingHooks()])

Documentation PR

https://github.com/deepyes02/sdk-python-strand-agents.git

Type of Change

Documentation update

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

  • Not really, this is just text updates.

Checklist

  • [ yes ] I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • [ yes] I have updated the documentation accordingly
  • [ yes] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • [ yes] 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.

…ocationEvent & AfterInvocationEvent respectively in the docstring for api reference documentation
Copy link
Member

@dbschmigelski dbschmigelski left a comment

Choose a reason for hiding this comment

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

Thanks for this!

@dbschmigelski dbschmigelski merged commit 2db5226 into strands-agents:main Sep 3, 2025
11 of 12 checks passed
@dbschmigelski
Copy link
Member

Merged even though integ test was failing. This has since been fixed in #785 and will not reoccur in new PRs which have rebased.

@dbschmigelski dbschmigelski changed the title Fix(doc): Replaced StartRequestEvent & EndRequestEvent with BeforeIn… fix(doc): replace invalid Hook names in doc comment with BeforeInvocationEvent & AfterInvocationEvent Sep 3, 2025
This was referenced Sep 17, 2025
Unshure pushed a commit to Unshure/sdk-python that referenced this pull request Sep 24, 2025
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