From 11f1880c02167eed52cb13474b4891f5948f95d4 Mon Sep 17 00:00:00 2001 From: Michael-lhh Date: Sat, 28 Feb 2026 00:18:00 +0800 Subject: [PATCH] fix: handle list-type tool arguments in _tool_hint Some models (e.g., Kimi K2.5 via OpenRouter) return tool call arguments as a list instead of a dict. This caused an AttributeError when trying to call .values() on the list. The fix checks if arguments is a list and extracts the first element before accessing .values(). Made-with: Cursor --- nanobot/agent/loop.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index 6fe37e9..e30ed23 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -163,7 +163,10 @@ class AgentLoop: def _tool_hint(tool_calls: list) -> str: """Format tool calls as concise hint, e.g. 'web_search("query")'.""" def _fmt(tc): - val = next(iter(tc.arguments.values()), None) if tc.arguments else None + args = tc.arguments + if isinstance(args, list) and args: + args = args[0] + val = next(iter(args.values()), None) if isinstance(args, dict) and args else None if not isinstance(val, str): return tc.name return f'{tc.name}("{val[:40]}…")' if len(val) > 40 else f'{tc.name}("{val}")'