Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(bot): fix Telegram channel init crash and empty content for Claude (#421)

ponsde791fa3c428c1
diff --git a/bot/vikingbot/agent/context.py b/bot/vikingbot/agent/context.py
index 23684b96c..83a9a44cb 100644
--- a/bot/vikingbot/agent/context.py
+++ b/bot/vikingbot/agent/context.py
@@ -6,8 +6,6 @@ import platform
from pathlib import Path
from typing import Any
-from loguru import logger
-
from vikingbot.agent.memory import MemoryStore
from vikingbot.agent.skills import SkillsLoader
from vikingbot.config.schema import SessionKey
@@ -89,7 +87,7 @@ class ContextBuilder:
if self.sandbox_manager:
sandbox_cwd = await self.sandbox_manager.get_sandbox_cwd(session_key)
parts.append(
- f"## Sandbox Environment\nYou are running in a sandboxed environment. All file operations and command execution are restricted to the sandbox directory.\nThe sandbox root directory is `{sandbox_cwd}` (use relative paths for all operations)."
+ f"## Sandbox Environment\n\nYou are running in a sandboxed environment. All file operations and command execution are restricted to the sandbox directory.\nThe sandbox root directory is `{sandbox_cwd}` (use relative paths for all operations)."
)
# Add session context
@@ -150,8 +148,8 @@ Skills with available="false" need dependencies installed first - you can try in
async def _get_identity(self, session_key: SessionKey) -> str:
"""Get the core identity section."""
- from datetime import datetime
import time as _time
+ from datetime import datetime
now = datetime.now().strftime("%Y-%m-%d %H:%M (%A)")
tz = _time.strftime("%Z") or "UTC"
@@ -166,6 +164,7 @@ Skills with available="false" need dependencies installed first - you can try in
workspace_display = workspace_path
return f"""# vikingbot 🐈
+
You are VikingBot, an AI assistant built based on the OpenViking context database.
When acquiring information, data, and knowledge, you **prioritize using openviking tools to read and search OpenViking (a context database) above all other sources**.
You have access to tools that allow you to:
@@ -307,7 +306,10 @@ Always be helpful, accurate, and concise. When using tools, think step by step:
Returns:
Updated message list.
"""
- msg: dict[str, Any] = {"role": "assistant", "content": content or ""}
+ msg: dict[str, Any] = {"role": "assistant"}
+
+ if content:
+ msg["content"] = content
if tool_calls:
msg["tool_calls"] = tool_calls