Skip to content

Conversation

0xnavarro
Copy link

Problem

The MLE-STAR agent crashes with a TypeError: can only concatenate str (not "NoneType") to str when processing LLM responses that contain parts with None text values.

Solution

Added a null check in get_text_from_response() to verify that response.content.parts[i].text is not None before concatenating it to the final text string.

Changes

  • Modified machine_learning_engineering/shared_libraries/common_util.py
  • Added condition: and response.content.parts[i].text is not None

Impact

  • Prevents agent crashes during task execution
  • Improves robustness when handling malformed or incomplete LLM responses
  • Maintains backward compatibility

Fixes a critical bug that could cause the MLE-STAR system to crash unexpectedly.

…ext values

- Add null check before concatenating response.content.parts[i].text
- Prevents 'TypeError: can only concatenate str (not "NoneType") to str'
- Improves robustness when LLM responses contain parts with None text values
- Fixes agent crashes during task execution that could occur with certain tasks

The error occurred in machine_learning_engineering/shared_libraries/common_util.py
when the agent attempted to concatenate None values from LLM response parts,
causing the MLE-STAR system to crash unexpectedly during execution.
@0xnavarro
Copy link
Author

This change is necessary because, without the explicit check for response.content.parts[i].text is not None, the code may attempt to concatenate a None value, which causes a crash. In real usage, I have encountered cases where response.content.parts[i].text exists as an attribute but is actually None, leading to runtime errors. With this improvement, the code works reliably and avoids unexpected failures. Without it, the current implementation is not safe for production use.

@ivanmkc
Copy link
Collaborator

ivanmkc commented Aug 13, 2025

@raj-sinha can you review?

@0xnavarro
Copy link
Author

@raj-sinha Could you please review it? Thank you.

@0xnavarro
Copy link
Author

If there’s no maintenance for this repo, please consider archiving it or explicitly stating that it’s not suitable for production use.

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