Skip to content

Agent Zero AI framework

SSH + chat deletion fix

frdelba2d5c7a674f
diff --git a/agent.py b/agent.py
index 8ee08a743..e81cbf99f 100644
--- a/agent.py
+++ b/agent.py
@@ -44,6 +44,9 @@ class AgentContext:
AgentContext._counter += 1
self.no = AgentContext._counter
+ existing = self._contexts.get(self.id, None)
+ if existing:
+ AgentContext.remove(self.id)
self._contexts[self.id] = self
@staticmethod
diff --git a/python/helpers/persist_chat.py b/python/helpers/persist_chat.py
index b170e7935..76d43b5eb 100644
--- a/python/helpers/persist_chat.py
+++ b/python/helpers/persist_chat.py
@@ -33,6 +33,7 @@ def load_json_chats(jsons: list[str]):
ctxids = []
for js in jsons:
data = json.loads(js)
+ if "id" in data: del data["id"] # remove id to get new
ctx = _deserialize_context(data)
ctxids.append(ctx.id)
return ctxids
@@ -102,7 +103,7 @@ def _deserialize_context(data):
context = AgentContext(
config=config,
- # id=data.get("id", None), #get new id
+ id=data.get("id", None), #get new id
name=data.get("name", None),
log=log,
paused=False,
diff --git a/python/helpers/shell_ssh.py b/python/helpers/shell_ssh.py
index 5eb7730a5..7aa6d52f0 100644
--- a/python/helpers/shell_ssh.py
+++ b/python/helpers/shell_ssh.py
@@ -33,7 +33,12 @@ class SSHInteractiveSession:
while True:
try:
self.client.connect(
- self.hostname, self.port, self.username, self.password
+ self.hostname,
+ self.port,
+ self.username,
+ self.password,
+ allow_agent=False,
+ look_for_keys=False,
)
self.shell = self.client.invoke_shell(width=160, height=48)
# self.shell.send(f'PS1="{SSHInteractiveSession.ps1_label}"'.encode())
diff --git a/run_ui.py b/run_ui.py
index 2ef00520e..a03eab9c5 100644
--- a/run_ui.py
+++ b/run_ui.py
@@ -204,7 +204,7 @@ async def load_chats():
return jsonify(response)
-# load chats from json
+# save chats to json
@app.route("/exportChat", methods=["POST"])
async def export_chat():
try:
@@ -219,7 +219,7 @@ async def export_chat():
response = {
"ok": True,
- "message": "Chats loaded.",
+ "message": "Chats exported.",
"ctxid": context.id,
"content": content,
}