💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Honor an empty allow list in the bash agent tool (#1362)
D419100e7202caeee6
diff --git a/src/python/txtai/agent/tool/bash.py b/src/python/txtai/agent/tool/bash.pyindex c000a19c..b847c5e5 100644--- a/src/python/txtai/agent/tool/bash.py+++ b/src/python/txtai/agent/tool/bash.py@@ -32,7 +32,7 @@ class BashTool(Tool):self.output_type = "any"# Default list of allowed commands- self.allowed = allowed if allowed else ["cat", "cut", "diff", "grep", "head", "ls", "tail"]+ self.allowed = allowed if allowed is not None else ["cat", "cut", "diff", "grep", "head", "ls", "tail"]# Maximum time to wait for a command, None waits indefinitelyself.timeout = timeoutdiff --git a/test/python/testagent.py b/test/python/testagent.pyindex 107ca317..e5b1a024 100644--- a/test/python/testagent.py+++ b/test/python/testagent.py@@ -232,6 +232,21 @@ class TestAgent(unittest.TestCase):# Timeout is disabled when set to Noneself.assertIsNone(BashTool(timeout=None).timeout)+ def testToolsBashAllowedEmpty(self):+ """+ Test an empty allowed commands list permits no commands+ """++ # An empty allow list is an explicit choice and must be honored, not replaced by the defaults+ self.assertEqual(BashTool(allowed=[]).allowed, [])++ # No command runs when nothing is allowed+ self.assertIsNone(BashTool(allowed=[])(["cat", "file.txt"]))++ # The defaults still apply when allowed isn't set, including an explicit None+ self.assertEqual(BashTool().allowed, ["cat", "cut", "diff", "grep", "head", "ls", "tail"])+ self.assertEqual(BashTool(allowed=None).allowed, ["cat", "cut", "diff", "grep", "head", "ls", "tail"])+@patch("subprocess.run")def testToolsBashEncoding(self, run):"""