Skip to content

Change to when tool call is on auto parsing #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged

Conversation

icwhite
Copy link
Collaborator

@icwhite icwhite commented Jul 10, 2025

Change in debug_gym/llms/openai.py for when a tool call could be an empty list as well as None. This prevents this error:

       │ /home/t-iwhite/debug-gym/debug_gym/llms/base.py:351 in generate_with_drop_message_and_retry                                 │          
         │                                                                                                                             │          
         │   348 │   │   │   if not messages:                                                                                          │          
         │   349 │   │   │   │   raise ValueError("No messages provided for generation.")                                              │          
         │   350 │   │   │   try:                                                                                                      │          
         │ ❱ 351 │   │   │   │   llm_response = self.generate(messages, tools, **kwargs)                                               │          
         │   352 │   │   │   except ContextLengthExceededError:                                                                        │          
         │   353 │   │   │   │   self.logger.info(                                                                                     │          
         │   354 │   │   │   │   │   f"Prompt is too long. {self.model_name} only allows for                                           │          
         │       {self.context_length:,} tokens."                                                                                      │          
         │                                                                                                                             │          
         │ /home/t-iwhite/debug-gym/debug_gym/llms/openai.py:226 in generate                                                           │          
         │                                                                                                                             │          
         │   223 │   │   │   # LLM failed to call a tool                                                                               │          
         │   224 │   │   │   tool_call = None                                                                                          │          
         │   225 │   │   else:                                                                                                         │          
         │ ❱ 226 │   │   │   tool_call = response.choices[0].message.tool_calls[0]                                                     │          
         │   227 │   │   │   assert tool_call.type == "function"  

@xingdi-eric-yuan
Copy link
Collaborator

LGTM, thank you!

@xingdi-eric-yuan xingdi-eric-yuan merged commit 411670c into main Jul 10, 2025
6 checks passed
@xingdi-eric-yuan xingdi-eric-yuan deleted the empty_list branch July 10, 2025 15:59
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