Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: agent import json decode error [LET-6338] (#6405)

cthomas6b64842c486b
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py
index 0d190cca6..3fd312116 100644
--- a/letta/server/rest_api/routers/v1/agents.py
+++ b/letta/server/rest_api/routers/v1/agents.py
@@ -389,6 +389,10 @@ async def import_agent(
file_size_mb = len(serialized_data) / (1024 * 1024)
logger.info(f"Agent import: loaded {file_size_mb:.2f} MB into memory")
agent_json = json.loads(serialized_data)
+
+ # Handle double-encoded JSON (if the result is a string, parse it again)
+ if isinstance(agent_json, str):
+ agent_json = json.loads(agent_json)
except json.JSONDecodeError:
raise HTTPException(status_code=400, detail="Corrupted agent file format.")