griptape icon indicating copy to clipboard operation
griptape copied to clipboard

Support case when model returns empty Actions list

Open andrewfrench opened this issue 1 month ago • 0 comments

This PR addresses a reported issue when parsing a list of Actions while initializing an ActionsSubtask.

In some cases, Models include an empty list of Actions in their responses. We currently raise a SchemaError this happens:

[05/11/24 12:58:44] INFO     ToolkitTask 9f94e60e40d04516b9cce029eab11a25                                                                                     
                             Input: hi my name is jason                                                                                                       
[05/11/24 12:58:47] ERROR    Subtask 9f94e60e40d04516b9cce029eab11a25                                                                                         
                             Invalid action JSON: Array item count 0 is less than minimum count of 1.                                                         
                    INFO     Subtask 3352ba0de32041969bbb7d9781a8c236                                                                                         
                             Thought: The user has introduced himself as Jason. There is no specific question or request, so I will acknowledge the           
                             introduction and ask how I can assist him.                                                                                       
                             Actions: []                                                                                                                      
                             Answer: Hi Jason! How can I assist you today?                                                                                    
                    INFO     Subtask 3352ba0de32041969bbb7d9781a8c236                                                                                         
                             Response: Action JSON validation error: Array item count 0 is less than minimum count of 1.                                      

If the model does not return an Actions list at all, we do not attempt to parse actions and do not raise an exception. In both cases the model is electing to take no actions. If "no actions" is a valid response, allowing one case and disallowing another is inconsistent behavior.

andrewfrench avatar May 14 '24 16:05 andrewfrench