Skip to content

Conversation

@AbdulSamad94
Copy link
Contributor

Summary

This PR adds runtime type validation to the prompt_with_handoff_instructions function to ensure it only accepts string inputs. Previously, the function had a type hint but no runtime validation, so passing non-string types did not raise any error, which could lead to unexpected behavior or silent failures.

Changes

  • Added isinstance(prompt, str) check in prompt_with_handoff_instructions
  • Raises TypeError with descriptive message when non-string types are provided
  • Updated function docstring to document the new validation and exception

Testing

The validation has been tested with various input types:

  • Valid strings: Work as expected
  • Invalid types (int, list, None, etc.): Previously caused silent failures, now properly raise TypeError with a clear message

Ensure that the prompt parameter is validated as a string at runtime, preventing unexpected behavior when non-string types are passed.
The function now raises a TypeError with a descriptive message when invalid types are provided.
@seratch
Copy link
Member

seratch commented Oct 14, 2025

Thanks for sending this PR. However, we prefer suggesting to use mypy or similar solution to detect this type of coding error.

@seratch seratch closed this Oct 14, 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.

2 participants