Skip to content

Conversation

@Unshure
Copy link
Member

@Unshure Unshure commented Feb 3, 2026

Description

This PR applies the fix from PR #260 to correct the callback handler example in the Python quickstart guide. The original example contained code that would not work as expected.

Changes

  • Configure logging properly: Added logging.basicConfig(level=logging.INFO) and use logging.getLogger() (without name) so log messages are actually visible
  • Fix streaming data access: Changed from kwargs["data"] to kwargs['delta'] which is the correct key for streamed content
  • Remove invalid argument: Removed end="" from logger.info() calls as this is not a valid argument for the logging API
  • Improve output format: Changed final print to print(f"\n{result}") for cleaner output

Why

The original callback handler example didn't work because:

  1. Logger wasn't configured to display INFO level messages
  2. The data key doesn't exist in kwargs - delta is the correct key
  3. logger.info() doesn't accept end="" like print() does

Testing

Verified changes match PR #260 which was tested locally by the author.

Resolves #519

- Configure logging with basicConfig(level=logging.INFO) for proper output
- Use kwargs['delta'] instead of kwargs['data'] for streaming data
- Remove invalid end='' argument from logger.info calls
- Use print(f"\n{result}") for cleaner output format

Resolves #519
@Unshure
Copy link
Member Author

Unshure commented Feb 3, 2026

/strands

@strands-agent
Copy link
Contributor

Documentation Deployment Complete

Your documentation preview has been successfully deployed!

Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-520/

@Unshure Unshure marked this pull request as draft February 3, 2026 18:36
@Unshure Unshure marked this pull request as ready for review February 3, 2026 18:36
@Unshure Unshure merged commit e89fa13 into main Feb 3, 2026
5 checks passed
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.

Fix Python quickstart guide

3 participants