From 33a00d9b8e7843ebff93526ebf9c582bbb8a5466 Mon Sep 17 00:00:00 2001 From: Shannon Sands Date: Sat, 14 Feb 2026 09:28:23 +1000 Subject: [PATCH] Agent loop: be robust to non-JSON tool args strings If tool_args_raw is not valid JSON at all (e.g. parser/provider passed through a plain string like ls), normalize it into {command: ...} for terminal or {input: ...} for other tools instead of dropping args. --- environments/agent_loop.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/environments/agent_loop.py b/environments/agent_loop.py index ffb9e61881..6e44aadf9d 100644 --- a/environments/agent_loop.py +++ b/environments/agent_loop.py @@ -246,7 +246,11 @@ class HermesAgentLoop: try: decoded = json.loads(tool_args_raw) except json.JSONDecodeError: - return {}, False + # Not valid JSON at all. Be robust: treat it as a plain string. + # (Some parsers/providers may pass through non-JSON strings.) + if tool_name == "terminal": + return {"command": tool_args_raw}, False + return {"input": tool_args_raw}, False # Canonical case: decoded is already a dict if isinstance(decoded, dict):