What happened?
Bug Description
In openharness/engine/query.py, the _record_tool_carryover() function performs a direct int() conversion on the offset parameter without handling string values that represent floating-point numbers.
When the offset argument from a read_file tool call is a string like '250.0', the code fails with:
ValueError: invalid literal for int() with base 10: '250.0'
Relevant Code
File: openharness/engine/query.py
Function: _record_tool_carryover()
Line: ~409
# Current code (problematic):
offset = int(tool_input.get("offset") or 0)
# This fails when tool_input["offset"] == "250.0"
Note: A similar conversion for limit on line ~412 already uses int(float(...)):
limit = int(float(limit_val or 200))
This inconsistency suggests the offset conversion should also use int(float(...)) for robustness.
Steps to reproduce
- Execute any tool call where
offset is passed as a float string (e.g., '250.0')
- The error occurs in
_record_tool_carryover() when recording the tool carryover for read_file
- The Gateway session fails until a restart
Expected Behavior
The code should handle:
- Integer values:
250
- Float values:
250.0
- String integers:
'250'
- String floats:
'250.0'
Environment
- Package:
openharness-ai
- Version:
0.1.9
- Python: 3.12.13
- OS: Linux 13 (trixie)
Stack Trace
File "/usr/local/lib/python3.12/site-packages/ohmo/gateway/bridge.py", line 260, in _process_message
async for update in self._runtime_pool.stream_message(message, session_key):
File "/usr/local/lib/python3.12/site-packages/ohmo/gateway/runtime.py", line 306, in stream_message
async for update in self._stream_engine_message(
File "/usr/local/lib/python3.12/site-packages/ohmo/gateway/runtime.py", line 414, in _stream_engine_message
async for event in bundle.engine.submit_message(user_message):
File "/usr/local/lib/python3.12/site-packages/openharness/engine/query_engine.py", line 185, in submit_message
async for event, usage in run_query(context, query_messages):
File "/usr/local/lib/python3.12/site-packages/openharness/engine/query.py", line 823, in run_query
result = await _execute_tool_call(context, tc.name, tc.id, tc.input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/openharness/engine/query.py", line 985, in _execute_tool_call
_record_tool_carryover(
File "/usr/local/lib/python3.12/site-packages/openharness/engine/query.py", line 409, in _record_tool_carryover
offset = int(tool_input.get("offset") or 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '250.0'
Suggested Fix
Change line 409 from:
offset = int(tool_input.get("offset") or 0)
To:
offset = int(float(tool_input.get("offset") or 0))
This aligns with the existing pattern on line ~412 for the limit parameter.
Additional Notes
- This issue was discovered when running a Gateway session that executed multiple
read_file tool calls
- The error occurred inconsistently - sometimes with offset
'240.0', sometimes with '250.0'
- Restarting the Gateway temporarily resolved the issue (suggesting a caching or serialization issue)
- The error prevents any tool calls that involve file reading from completing successfully
- The Gateway requires a restart to recover from this error state
Relevant logs or screenshots
What happened?
Bug Description
In
openharness/engine/query.py, the_record_tool_carryover()function performs a directint()conversion on theoffsetparameter without handling string values that represent floating-point numbers.When the
offsetargument from aread_filetool call is a string like'250.0', the code fails with:Relevant Code
File:
openharness/engine/query.pyFunction:
_record_tool_carryover()Line: ~409
Note: A similar conversion for
limiton line ~412 already usesint(float(...)):This inconsistency suggests the
offsetconversion should also useint(float(...))for robustness.Steps to reproduce
offsetis passed as a float string (e.g.,'250.0')_record_tool_carryover()when recording the tool carryover forread_fileExpected Behavior
The code should handle:
250250.0'250''250.0'Environment
openharness-ai0.1.9Stack Trace
Suggested Fix
Change line 409 from:
To:
This aligns with the existing pattern on line ~412 for the
limitparameter.Additional Notes
read_filetool calls'240.0', sometimes with'250.0'Relevant logs or screenshots