Skip to content

Commit 20d583f

Browse files
committed
fix(parsers): handle empty dict in streaming tool calls
1 parent cfa7c58 commit 20d583f

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

kiro/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def _warn_timeout_configuration():
550550
# Application Version
551551
# ==================================================================================================
552552

553-
APP_VERSION: str = "2.4-dev.10"
553+
APP_VERSION: str = "2.4-rc.2"
554554
APP_TITLE: str = "Kiro Gateway"
555555
APP_DESCRIPTION: str = "Proxy gateway for Kiro API (Amazon Q Developer / AWS CodeWhisperer). OpenAI and Anthropic compatible. Made by @jwadow"
556556

kiro/parsers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,12 @@ def _process_tool_start_event(self, data: dict) -> Optional[Dict[str, Any]]:
356356
# input can be string or object
357357
input_data = data.get('input', '')
358358
if isinstance(input_data, dict):
359-
input_str = json.dumps(input_data)
359+
if input_data:
360+
# Non-empty dict: serialize it
361+
input_str = json.dumps(input_data)
362+
else:
363+
# Empty dict {}: fragments will follow, use empty string
364+
input_str = ''
360365
else:
361366
input_str = str(input_data) if input_data else ''
362367

@@ -380,7 +385,10 @@ def _process_tool_input_event(self, data: dict) -> Optional[Dict[str, Any]]:
380385
# input can be string or object
381386
input_data = data.get('input', '')
382387
if isinstance(input_data, dict):
383-
input_str = json.dumps(input_data)
388+
if input_data:
389+
input_str = json.dumps(input_data)
390+
else:
391+
input_str = ''
384392
else:
385393
input_str = str(input_data) if input_data else ''
386394
self.current_tool_call['function']['arguments'] += input_str
@@ -428,6 +436,7 @@ def _finalize_tool_call(self) -> None:
428436
f"Tool call truncated by Kiro API: "
429437
f"tool='{tool_name}', id={tool_id}, size={truncation_info['size_bytes']} bytes, "
430438
f"reason={truncation_info['reason']}. "
439+
f"This is a Kiro API limitation. "
431440
f"{'Model will be notified automatically about truncation.' if TRUNCATION_RECOVERY else 'Set TRUNCATION_RECOVERY=true in .env to auto-notify model about truncation.'}"
432441
)
433442
else:

0 commit comments

Comments
 (0)