Skip to content

Fix ensure_list splitting str/bytes into characters - #266

Merged
zRzRzRzRzRzRzR merged 1 commit into
zai-org:mainfrom
winklemad:fix-ensure-list-str-explosion
Jul 21, 2026
Merged

zRzRzRzRzRzRzR merged 1 commit into
zai-org:mainfrom
winklemad:fix-ensure-list-str-explosion

Conversation

@winklemad

Copy link
Copy Markdown
Contributor

ensure_list() uses isinstance(obj, Sequence) to decide whether to wrap or spread its argument, but str/bytes are Sequence subclasses — so a single string is exploded into one-character elements instead of being wrapped as ["the string"].

This corrupts the documented Union[Sequence[str], str] inputs:

  • RewardSystem.get_reward — a single-string prompts/answers/gt_answers is scored one character at a time.
  • Every verifier's LLM-judge fallback — a scalar llm_api_key/llm_judge_url/llm_model. This scalar form is the one shipped in the project's own configs/full_config.yaml, so when the fallback fires the judge URL is requested one character at a time and then crashes with ValueError: zip() argument 3 is shorter than arguments 1-2.

Treat str/bytes/bytearray as scalar before the Sequence check. Adds tests for the previously-untested misc helpers.

ensure_list is meant to normalize a single value or a sequence into a
list, but str and bytes are themselves Sequence subclasses, so a single
string was split into one-character elements instead of wrapped as
["the string"].

This misfires on the documented Union[Sequence[str], str] inputs. In
RewardSystem.get_reward, passing a single prompt/answer/gt as a string
scores every character as a separate example. In the verifier LLM-judge
fallback, a scalar llm_api_key / llm_judge_url / llm_model (the form used
throughout configs/full_config.yaml, e.g. the mmsi verifier) gets
exploded character-by-character; the judge then fires one request per URL
character and finally crashes with "ValueError: zip() argument 3 is
shorter than arguments 1-2".

Treat str/bytes/bytearray as scalar values, and add tests for the misc
helpers, which had none.
@zRzRzRzRzRzRzR
zRzRzRzRzRzRzR merged commit 726dac5 into zai-org:main Jul 21, 2026
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