Skip to content

Conversation

athewsey
Copy link
Contributor

@athewsey athewsey commented Oct 8, 2025

Description

Add the incoming messages to BeforeInvocationEvent, so that this hook can be used for implementing guardrails that check (and perhaps redact) user inputs before kicking off the event loop or raising MessageAddedEvents.

Related Issues

#1006

Documentation PR

None yet - Should be some small updates required if we go ahead. I can work on this if reviewers are OK with the change in principle?

Type of Change

New feature

Testing

Updated existing unit tests to validate the messages are passed through correctly (both in structured output and normal agent invocation).

⚠️ For now I have not added any test to explicitly validate that if a BeforeInvocationEvent hook edits the input messages in place, these will be reflected in the rest of the invocation. Do we want to commit to this?

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • (⚠️ See note above) 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.

@athewsey athewsey changed the title feat: expose messages to BeforeInvocationEvent Expose input messages to BeforeInvocationEvent Oct 8, 2025
Add incoming messages to BeforeInvocationEvent so this hook can be
used for guardrails aiming to check (and perhaps redact) user inputs
before kicking off the event loop.
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