Agent Zero AI framework
SSH output cleanup, delegation fix
frdel281061f351f0
diff --git a/main.py b/main.pyindex 279477099..60b1da7c7 100644--- a/main.py+++ b/main.py@@ -18,11 +18,11 @@ def initialize():# chat_llm = models.get_groq_llama70b(temperature=0.2)# chat_llm = models.get_groq_llama70b_json(temperature=0.2)# chat_llm = models.get_groq_llama8b(temperature=0.2)- # chat_llm = models.get_openai_gpt35(temperature=0)+ chat_llm = models.get_openai_gpt35(temperature=0)# chat_llm = models.get_openai_gpt4o(temperature=0)# chat_llm = models.get_anthropic_opus(temperature=0)# chat_llm = models.get_anthropic_sonnet(temperature=0)- chat_llm = models.get_anthropic_sonnet_35(temperature=0)+ # chat_llm = models.get_anthropic_sonnet_35(temperature=0)# chat_llm = models.get_anthropic_haiku(temperature=0)# chat_llm = models.get_ollama_dolphin()diff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.pyindex fe3b7f88c..b980b7df9 100644--- a/python/helpers/shell_ssh.py+++ b/python/helpers/shell_ssh.py@@ -4,6 +4,11 @@ import refrom typing import Optional, Tupleclass SSHInteractiveSession:++ end_comment = "# @@==>> SSHInteractiveSession End-of-Command <<==@@"++ ps1_label = "SSHInteractiveSession CLI>"+def __init__(self, hostname: str, port: int, username: str, password: str):self.hostname = hostnameself.port = port@@ -20,11 +25,13 @@ class SSHInteractiveSession:while True:try:self.client.connect(self.hostname, self.port, self.username, self.password)- self.shell = self.client.invoke_shell()- while True: # wait for end of initial output- full, part = self.read_output()- if full and not part: return- time.sleep(0.1)+ self.shell = self.client.invoke_shell(width=160,height=48)+ # self.shell.send(f'PS1="{SSHInteractiveSession.ps1_label}"'.encode())+ return+ # while True: # wait for end of initial output+ # full, part = self.read_output()+ # if full and not part: return+ # time.sleep(0.1)except Exception as e:errors += 1if errors < 3:@@ -43,7 +50,7 @@ class SSHInteractiveSession:if not self.shell:raise Exception("Shell not connected")self.full_output = ""- self.shell.send((command + '\n').encode())+ self.shell.send((command + " \\\n" +SSHInteractiveSession.end_comment + "\n").encode())def read_output(self) -> Tuple[str, str]:if not self.shell:@@ -58,6 +65,12 @@ class SSHInteractiveSession:time.sleep(0.1) # Prevent busy waitingself.full_output = self.clean_string(self.full_output)++ # split output at end_comment+ if SSHInteractiveSession.end_comment in self.full_output:+ self.full_output = self.full_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")+ partial_output = partial_output.split(SSHInteractiveSession.end_comment)[-1].lstrip("\r\n")+return self.full_output, partial_outputdef clean_string(self, input_string):diff --git a/python/tools/call_subordinate.py b/python/tools/call_subordinate.pyindex 2d2f4c5e9..71f18e639 100644--- a/python/tools/call_subordinate.py+++ b/python/tools/call_subordinate.py@@ -8,10 +8,7 @@ class Delegation(Tool):def execute(self, message="", reset="", **kwargs):# create subordinate agent using the data object on this agent and set superior agent to his data objectif self.agent.get_data("subordinate") is None or str(reset).lower().strip() == "true":- # subordinate = Agent(system_prompt=self.agent.system_prompt, tools_prompt=self.agent.tools_prompt, number=self.agent.number+1)- config = self.agent.__dict__.copy()- config["agent_number"] = self.agent.number+1- subordinate = Agent(**config)+ subordinate = Agent(self.agent.number+1, self.agent.config)subordinate.set_data("superior", self.agent)self.agent.set_data("subordinate", subordinate)# run subordinate agent message loop