Skip to content

Conversation

zastrowm
Copy link
Member

Description

In the switch to typed_events, the case of structured_output invoking the callback handler was missed, resulting in a break in backwards compatibility (see issue #831); this restores the old behavior/fixes backwards compatibility

Important

I'm not sure we want this behavior

I'm not entirely convinced we want this behavior - compared to the other callback handlers, the events emitted from Agent.structured_output are very provider & implementation-specific. For instance:

  • Right now bedrock emits a bunch of events because we implemented via tools; if we changed that, the events emitted would change.
  • The other providers (like OpenAI) do not emit any events as they provide apis to perform structured_output

I would like to discuss further with the team regarding the issue; I see a couple of paths forward:

  1. We merge this fix in for backwards compatibility
  2. We decide that callback_handlers should not be invoked for structured_output
  3. We decide (2) is correct, but (1) and revert this in 2.0

Testing

I tested the events emitted before and after typed events were introduced and the test passed in both cases.

Related Issues

#831

Documentation PR

N/A

Type of Change

Bug fix

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.

In the switch to typed_events, the case of structured_output invoking the callback handler was missed, resulting in issue strands-agents#831; this restores the old behavior/fixes backwards compatibility
@zastrowm zastrowm enabled auto-merge (squash) September 16, 2025 13:23
@zastrowm zastrowm merged commit a36255d into strands-agents:main Sep 18, 2025
11 of 12 checks passed
@Unshure Unshure mentioned this pull request Sep 19, 2025
7 tasks
Unshure pushed a commit to Unshure/sdk-python that referenced this pull request Sep 24, 2025
In the switch to typed_events, the case of structured_output invoking the callback handler was missed, resulting in issue strands-agents#831; this restores the old behavior/fixes backwards compatibility

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