diff --git a/README.md b/README.md index a474367..289ff28 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ⚡️ Delivers core agent functionality in just **~4,000** lines of code — **99% smaller** than Clawdbot's 430k+ lines. -📏 Real-time line count: **3,761 lines** (run `bash core_agent_lines.sh` to verify anytime) +📏 Real-time line count: **3,781 lines** (run `bash core_agent_lines.sh` to verify anytime) ## 📢 News diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index 889921a..6bdf6ff 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -451,6 +451,14 @@ class AgentLoop: ## Conversation to Process {conversation} +**IMPORTANT**: Both values MUST be strings, not objects or arrays. + +Example: +{{ + "history_entry": "[2026-02-14 22:50] User asked about...", + "memory_update": "- Host: HARRYBOOK-T14P\n- Name: Nado" +}} + Respond with ONLY valid JSON, no markdown fences.""" try: @@ -473,8 +481,14 @@ Respond with ONLY valid JSON, no markdown fences.""" return if entry := result.get("history_entry"): + # Defensive: ensure entry is a string (LLM may return dict) + if not isinstance(entry, str): + entry = json.dumps(entry, ensure_ascii=False) memory.append_history(entry) if update := result.get("memory_update"): + # Defensive: ensure update is a string + if not isinstance(update, str): + update = json.dumps(update, ensure_ascii=False) if update != current_memory: memory.write_long_term(update)