From 37ca487e0424c30cfd7c376191e1d4fe1217d1bb Mon Sep 17 00:00:00 2001 From: flobo3 Date: Tue, 17 Mar 2026 20:04:37 +0300 Subject: [PATCH] fix(agent): handle edge cases in tool hints path hiding --- nanobot/agent/loop.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index 4d6be3547..26fa697fc 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -184,21 +184,23 @@ class AgentLoop: val = None if isinstance(args, dict): - if "path" in args and isinstance(args["path"], str): - val = args["path"] - elif "query" in args and isinstance(args["query"], str): - val = args["query"] - else: - for v in args.values(): - if isinstance(v, str): - val = v - break + # Iterate through all string values to find the first meaningful one + for v in args.values(): + if isinstance(v, str): + val = v + break if not isinstance(val, str): return tc.name - if self.restrict_to_workspace and workspace_str in val: - val = val.replace(workspace_str, "").lstrip("\\/") + if self.restrict_to_workspace: + import os + # If it looks like an absolute path, normalize it to resolve '..' and '.' + if os.path.isabs(val): + val = os.path.normpath(val) + # Replace workspace path with empty string to hide it + if workspace_str in val: + val = val.replace(workspace_str, "").lstrip("\\/") return f'{tc.name}("{val[:40]}…")' if len(val) > 40 else f'{tc.name}("{val}")'