mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-30 06:45:55 +00:00
fix(agent): handle edge cases in tool hints path hiding
This commit is contained in:
parent
76fa8790dc
commit
37ca487e04
@ -184,21 +184,23 @@ class AgentLoop:
|
|||||||
|
|
||||||
val = None
|
val = None
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict):
|
||||||
if "path" in args and isinstance(args["path"], str):
|
# Iterate through all string values to find the first meaningful one
|
||||||
val = args["path"]
|
for v in args.values():
|
||||||
elif "query" in args and isinstance(args["query"], str):
|
if isinstance(v, str):
|
||||||
val = args["query"]
|
val = v
|
||||||
else:
|
break
|
||||||
for v in args.values():
|
|
||||||
if isinstance(v, str):
|
|
||||||
val = v
|
|
||||||
break
|
|
||||||
|
|
||||||
if not isinstance(val, str):
|
if not isinstance(val, str):
|
||||||
return tc.name
|
return tc.name
|
||||||
|
|
||||||
if self.restrict_to_workspace and workspace_str in val:
|
if self.restrict_to_workspace:
|
||||||
val = val.replace(workspace_str, "").lstrip("\\/")
|
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}")'
|
return f'{tc.name}("{val[:40]}…")' if len(val) > 40 else f'{tc.name}("{val}")'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user