isekOS / ISEK

A decentralized agent network for building collaborative, LLM-powered agent-to-agent (A2A) systems.
https://docs.isek.xyz/
MIT License
243 stars 36 forks source link

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

Closed Edward9292 closed 6 days ago

Edward9292 commented 2 months ago

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.

SparkssL commented 2 months ago

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.