Allow None for timeout in AskSpec to support indefinite waits #925
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Updated the AskSpec data class to support
None
as a valid value for thetimeout
field, allowing developers to force a wait without a timeout constraint. Previously, passingtimeout = None
would trigger a Pydantic validation error, making the only solution to pass an extremely large integer to achieve a pseudo-infinite wait.Changes
int
toOptional[int]
within the AskSpec data class.AskUserMessage
,AskFileMessage
, andAskUserAction
by passingtimeout = None
.types.py
file has several adjustments to it's spacing and import structure as a result of the pre-commit hook set up in your repository, the only thing I actually changed was one line.Rationale
When asking the user for a file, for example, before a model can answer question, it's possible to not want the operation to timeout ever. The user may leave their computer and move onto something else for hours, but the file input should still work. Setting the variable
timeout = None
is very intuitive and clearly shows the intention of the developer to not allow a timeout to occur.Testing
AskUserMessage
,AskFileMessage
, andAskUserAction
worked with passingtimeout = None
with this change, and they all did as far as I could tell.