Skip to content

Fix int() crash on float strings and model alias suffix stripping - #322

Open
sridhar-3009 wants to merge 2 commits into
HKUDS:mainfrom
sridhar-3009:fix/302-int-float-string-carryover
Open

Fix int() crash on float strings and model alias suffix stripping#322
sridhar-3009 wants to merge 2 commits into
HKUDS:mainfrom
sridhar-3009:fix/302-int-float-string-carryover

Conversation

@sridhar-3009

Copy link
Copy Markdown

Fixes #302, #308, #312

Changes

Fix 1: _record_tool_carryover() crashes on float-format numeric strings (fixes #302)

File: src/openharness/engine/query.py

Some LLMs emit JSON integer fields as floats (e.g. 250.0 instead of 250). int() raises ValueError on such strings. Wrapping with float() first handles both integer and float-formatted numeric strings:

# Before
offset = int(tool_input.get("offset") or 0)
limit = int(tool_input.get("limit") or 200)

# After
offset = int(float(tool_input.get("offset") or 0))
limit = int(float(tool_input.get("limit") or 200))

Fix 2: Async subprocess stdout data loss between chunks (fixes #308)

File: src/openharness/tasks/manager.py

_copy_output() writes 4 KB chunks to disk but never calls flush(). If the subprocess exits abruptly between iterations, data sitting in the Python file buffer is lost. Added handle.flush() after handle.write(chunk).

Fix 3: MiniMax [1M] model alias suffix rejected by API (fixes #312)

File: src/openharness/config/settings.py

resolve_model_setting() was passing display aliases like MiniMax-M3[1M] raw to the provider API, causing a 400 unknown model error. Added a regex strip for any trailing [N K/M] context-window suffix before returning the resolved model ID. This is consistent with how Claude handles similar display variants.

Some LLMs emit JSON numbers as floats (e.g. 250.0 instead of 250).
int() raises ValueError on such strings; wrapping with float() first
handles both integer and float-formatted numeric strings.

Fixes HKUDS#302
Two independent bug fixes:

1. _copy_output() (manager.py): each 4 KB chunk was written to disk but
   never flushed between iterations of the while-loop. If the subprocess
   exited abruptly, data sitting in the Python file buffer was lost.
   Adding handle.flush() after handle.write() keeps the on-disk file
   current across all chunk boundaries. Fixes HKUDS#308.

2. resolve_model_setting() (settings.py): display aliases like
   "MiniMax-M3[1M]" were passed raw to the provider API, causing a 400
   "unknown model" error. Strip any trailing [N K/M] context-window
   suffix before returning the resolved model ID. Fixes HKUDS#312.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant