Kaynağa Gözat

fix: Bash tool — don't intercept chained cd commands

'cd ~/app && git init' was caught by the pure-cd handler,
treating the entire chain as a directory path. Now only intercepts
simple 'cd <path>' without &&, ||, ;, | operators.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kenny67nju 7 ay önce
ebeveyn
işleme
382a444763
1 değiştirilmiş dosya ile 4 ekleme ve 2 silme
  1. 4 2
      lambdagent/builtin_tools/shell_tools.py

+ 4 - 2
lambdagent/builtin_tools/shell_tools.py

@@ -73,9 +73,11 @@ def run_bash(input_val: Any) -> str:
     working_dir = params.get("working_dir", "") or _get_cwd()
     background = params.get("run_in_background", False)
 
-    # Handle cd commands — update session CWD
+    # Handle pure cd commands — update session CWD
+    # Only intercept simple "cd <path>", not chained commands like "cd x && git init"
     stripped = command.strip()
-    if stripped.startswith("cd "):
+    is_pure_cd = stripped.startswith("cd ") and not any(op in stripped for op in ["&&", "||", ";", "|", "\n"])
+    if is_pure_cd:
         target = stripped[3:].strip().strip("'\"")
         if not os.path.isabs(target):
             target = os.path.join(working_dir, target)