ISEK icon indicating copy to clipboard operation
ISEK copied to clipboard

Bug Report: Program Raises Error Due to Inconsistent Response Format from Different LLMs

Open Edward9292 opened this issue 1 year ago • 1 comments

When will this bug raise:

When I run examples using different LLM models, I noticed that some models raise an error. For instance, using Google Gemini 2.5 to run coin_donation_game.py raises a TypeError: 'NoneType' object is not subscriptable in isek\agent\abstract_agent.py at line 102:

response = self.model.create( ... tool_schemas=tool_schemas or None, ).choices[0].message

Potential reason this error is happening:

The error occurs because the code assumes every model’s response always contains a .choices list with at least one element. However, some models like Google Gemini might return a different response structure or None for .choices, casing a TypeError when attempting to access .choices[0].message.

Thoughts on how to fix this bug:

We should not assume all models share the same response structure. Instead, the code should first validate the response object and its contents before accessing nested fields. Adding a response handler layer or interface to normalize and parse different model responses consistently could be a good approach to handle these variations safely.

Edward9292 avatar May 15 '25 19:05 Edward9292

Thanks for submitting this issue — great catch! I‘m openning a feature request to support pluggable model adapters, enabling ISEK to work seamlessly with OpenAI, Google Gemini, Claude, etc.

SparkssL avatar May 15 '25 19:05 SparkssL