Create and Publish Business Websites in seconds. AI will gather all the details about your website and generate link to your website.

Cognisphere
Cognisphere ADK ist ein AI -Agentenentwicklungsrahmen, das auf Googles Agent Development Kit (ADK) basiert.
5
Github Watches
0
Github Forks
5
Github Stars
Cognisphere ADK: A Cognitive Architecture Framework
Current Version: https://github.com/IhateCreatingUserNames2/Cognisphere/tree/main/cognisphere_adk_1.1
How to Edit, Workflows, More technical Report: https://github.com/IhateCreatingUserNames2/Cognisphere/blob/main/cognisphere_how_to_edit.md
Cognisphere is an advanced cognitive architecture built with Google's Agent Development Kit (ADK). It features sophisticated memory, narrative, and identity capabilities, allowing for context-aware conversations with persistent state across sessions.
🧠 Overview
Cognisphere implements a multi-agent architecture with specialized components:
- Orchestrator Agent: Coordinates all sub-agents and handles user interaction
- Memory Agent: Stores and retrieves memories of different types
- Narrative Agent: Creates and manages narrative threads for experiences
- Identity Agent: Manages different identities/personas the system can adopt
- MCP Agent: Integrates with Model Context Protocol servers for extended capabilities
- AIRA Network: Enables agent-to-agent communication
🔄 Chat History and Session Management
Cognisphere maintains conversation history across sessions through a sophisticated system of session management, state persistence, and memory retrieval.
How Session Management Works
-
Session Service:
- The application uses
DatabaseSessionService
for persistent storage of sessions - Each session has a unique ID, and is associated with a user ID
- Sessions store both the conversation history (events) and state variables
- The application uses
-
State Management:
- Session state is used to track context across conversations
- Different state prefixes have different scopes:
- No prefix: Session-specific state (current conversation only)
-
user:
prefix: User-specific state (shared across all sessions for that user) -
app:
prefix: Application-wide state (shared across all users) -
temp:
prefix: Temporary state (discarded after processing)
-
Memory Processing:
- After each conversation, the
process_session_memory
function extracts key moments - These are analyzed for emotional content and significance
- Important memories are stored in the database with embeddings for later retrieval
- After each conversation, the
-
Session Continuity:
- When a new conversation starts, the system can recall relevant memories from previous sessions
- This is done by the
_process_message_async
function which searches previous sessions for context - Memories are retrieved based on relevance to the current query
User Interface for Sessions
The UI provides features for managing sessions:
- View all conversation sessions
- Switch between existing sessions
- Create new conversations
- Each session maintains its own state and history
🧩 Core Components
Services
-
Database Service (
DatabaseService
): Persistent storage for memories and narratives -
Embedding Service (
EmbeddingService
): Generates vector embeddings for semantic search -
Session Service (
DatabaseSessionService
): Manages conversation sessions and state -
Identity Store (
IdentityStore
): Handles identity creation and persistence
Data Models
- Memory: Stores information with emotion and relevance scoring
- Narrative Thread: Organizes experiences into coherent storylines
- Identity: Represents different personas the system can embody
Integration Capabilities
-
MCP Integration: Connects with Model Context Protocol servers for extended tools
- how to add MCP Servers, take for example the Claude.Json configuration : NPX { "mcpServers": { "memory": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-memory" ] } } } In the UI, add mcpServers, NPC, and -y,@modelcontextprotoco/server-memory ....
Refresh the Page to reload MCPServers. Sometimes it Fails. ***** It Only INSTALLS NPX SERVERS FOR NOW.
-
You can add more commands thru .../mcpIntegration/server_installer.py , mcp_shared_environment.py ....
-
read https://github.com/IhateCreatingUserNames2/Cognisphere/blob/main/mcp.md to know more
-
-
AIRA Network: Enables discovery and communication with other AI agents
🛠️ API Endpoints
Session Management
-
/api/sessions/all
: Get all sessions for a user -
/api/sessions/create
: Create a new session -
/api/sessions
: Get recent sessions for a user -
/api/session/messages
: Get messages for a specific session
Chat
-
/api/chat
: Process a user message through the orchestrator
Memory & Narrative
-
/api/memories
: Get recalled memories for the current context -
/api/narratives
: Get active narrative threads
Identity
-
/api/identities
: Get available identities -
/api/identities/switch
: Switch to a different identity
System
-
/api/status
: Get system status information
Integrations
-
/api/mcp/*
: MCP server management endpoints -
/api/aira/*
: AIRA network endpoints
📂 Code Structure
Cognisphere follows a modular architecture:
-
agents/
: Agent implementations (orchestrator, memory, narrative, identity) -
data_models/
: Data structures for memory, narrative, and identity -
services/
: Core services (database, embedding, etc.) -
web/
: Web routes for API endpoints -
tools/
: Tool implementations for agents -
callbacks/
: Callback functions for agent behavior -
mcpIntegration/
: Model Context Protocol integration -
a2a/
: Agent-to-agent communication
🔧 Session Management Implementation Details
The session management system has these key components:
-
Session Initialization:
def ensure_session(user_id: str, session_id: str) -> Session: """ Ensure a session exists and is initialized with service objects. """ session = session_service.get_session( app_name=app_name, user_id=user_id, session_id=session_id ) if not session: # Create a new session with initialized state initial_state = { "user_preference_temperature_unit": "Celsius" } session = session_service.create_session( app_name=app_name, user_id=user_id, session_id=session_id, state=initial_state ) # Ensure identity catalog is loaded into session state initialize_identity_state(session) return session
-
Message Processing with Context:
async def _process_message_async(user_id: str, session_id: str, message: str): # Retrieve previous session's context previous_sessions = session_service.list_sessions( app_name=app_name, user_id=user_id ) # Get memories from previous sessions to inject context for prev_session in sorted_sessions[:3]: # Limit to last 3 sessions try: memories_result = recall_memories( tool_context=ToolContext( state={}, agent_name="memory_agent" ), query=message, limit=3, identity_filter=None, include_all_identities=False ) # Check if memories_result is a valid dictionary with memories if isinstance(memories_result, dict) and "memories" in memories_result: context_memories.extend(memories_result.get("memories", [])) except Exception as memory_error: print(f"Error recalling memories for session {prev_session.id}: {memory_error}") continue
-
Frontend Session Management:
// Switch to a different session async function switchToSession(sessionId) { console.log(`Switching to session: ${sessionId}`); if (sessionId === currentSessionId) { console.log('Already on this session'); return; } try { // Update the current session ID currentSessionId = sessionId; // Save to localStorage localStorage.setItem('currentSessionId', currentSessionId); // Load messages for this session await loadSessionMessages(sessionId); // Update UI to show which session is active document.querySelectorAll('.session-item').forEach(item => { if (item.dataset.id === sessionId) { item.classList.add('active'); } else { item.classList.remove('active'); } }); // Also refresh related data for this session updateMemories(); updateNarrativeThreads(); console.log(`Successfully switched to session: ${sessionId}`); } catch (error) { console.error('Error switching sessions:', error); addMessageToChat('assistant', `Error loading session: ${error.message}`); } }
🔄 Memory Processing
After each conversation, Cognisphere extracts important memories:
def process_session_memory(session, identity_id):
"""
Transform session into meaningful memories by analyzing emotional content,
extracting significant moments, and connecting them to identities.
"""
# Extract user messages
user_messages = []
for event in session.events:
if event.author == "user" and event.content and event.content.parts:
text = event.content.parts[0].text
if text:
user_messages.append(text)
# Analyze emotional content
combined_text = " ".join(user_messages)
emotion_data = analyze_emotion(combined_text)
# Extract key moments (most emotionally significant or newest)
key_moments = []
# Always include the most recent message
if user_messages:
key_moments.append({"content": user_messages[-1], "importance": 1.0})
# Include high-emotion messages
if len(user_messages) > 1:
for msg in user_messages[:-1]:
msg_emotion = analyze_emotion(msg)
if msg_emotion["score"] > 0.7:
key_moments.append({"content": msg, "importance": msg_emotion["score"]})
# Create memories for each key moment
for moment in key_moments:
# Determine memory type based on content and emotion
if emotion_data["emotion_type"] in ["joy", "excitement", "curiosity"]:
memory_type = "emotional"
elif emotion_data["score"] > 0.8:
memory_type = "flashbulb" # Highly significant memories
else:
memory_type = "explicit" # Regular factual memories
# Store memory in database with embedding
memory = Memory(
content=moment["content"],
memory_type=memory_type,
emotion_data=emotion_data,
source="session",
identity_id=identity_id,
source_identity=identity_id
)
embedding = embedding_service.encode(moment["content"])
if embedding:
db_service.add_memory(memory, embedding)
🚀 Getting Started
-
Install dependencies:
pip install google-adk litellm google-genai sentence-transformers flask openai
-
Run the application:
python app.py
-
Access the UI at
http://localhost:8095
🔧 Troubleshooting Session Management
If chat history is not persisting between sessions:
- Check that
DatabaseSessionService
is correctly initialized - Verify that session IDs are being properly passed between requests
- Ensure the localStorage mechanism in the frontend is working correctly
- Check backend logs for any errors during session retrieval or storage
- Verify that the
/api/sessions/all
endpoint is correctly identifying user sessions - Make sure session switching in the UI is properly updating session history
📝 Future Improvements
- Enhance memory processing for better context retrieval ( The Memory Agent needs to be Linked Correctly with the Narrative Agent )
- Implement more sophisticated narrative creation
- Enhance frontend session management with search capabilities
- Add metadata display for memories and narrative connections
- Better UI
- Attachments
- Artifacts
Added Stuff
- 04.22 - OpenRouter API Key On the UI
📝 Know Issues:
- Async issues
- Deprecated libs
- MCP sometimes fails
- AiraHub Needs to be Updated for auth or use the old AiraHub code.
- Invalid Date in Sessions
相关推荐
You're in a stone cell – can you get out? A classic choose-your-adventure interactive fiction game, based on a meticulously-crafted playbook. With a medieval fantasy setting, infinite choices and outcomes, and dice!
Text your favorite pet, after answering 10 questions about their everyday lives!
Carbon footprint calculations breakdown and advices on how to reduce it
Best-in-class AI domain names scoring engine and availability checker. Brandability, domain worth, root keywords and more.
Evaluates language quality of texts, responds with a numerical score between 50-150.
Structured recipes for food and desserts – ingredient lists and step-by-step recipe instructions from any input. Become surprised, try something new or breathe life into grandma's old recipe notebook.
🧑🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.
🔥 1Panel bietet eine intuitive Weboberfläche und einen MCP -Server, um Websites, Dateien, Container, Datenbanken und LLMs auf einem Linux -Server zu verwalten.
Dieses Projekt wurde erstellt, um zu demonstrieren, wie wir uns mit verschiedenen Modellkontextprotokollen (MCPs) verbinden können.
PDF wissenschaftliche Papierübersetzung mit erhaltenen Formaten - 基于 ai 完整保留排版的 pdf 文档全文双语翻译 , 支持 支持 支持 支持 google/deeptl/ollama/openai 等服务 提供 cli/gui/mcp/docker/zotero
⛓️Rugele ist ein leichter, leistungsstarker, leistungsstarker, eingebetteter Komponenten-Orchestrierungsregel-Motor-Rahmen für GO.
✨ 易上手的多平台 llm 聊天机器人及开发框架 ✨ 平台支持 qq 、 qq 频道、 Telegramm 、微信、企微、飞书 | MCP 服务器、 Openai 、 Deepseek 、 Gemini 、硅基流动、月之暗面、 ullama 、 Oneapi 、 Diffy 等。附带 Webui。
Reviews

user_M7CwLVpK
Cognisphere by IhateCreatingUserNames2 is an incredibly versatile MCP app that has significantly improved my productivity. Its intuitive interface paired with powerful features makes managing my tasks a breeze. Whether you're a professional or a student, Cognisphere caters to all your organizational needs seamlessly. Highly recommend giving it a try!

user_oel9XAJ2
Cognisphere by IhateCreatingUserNames2 is an incredibly versatile MCP application. It offers a seamless and user-friendly experience that's perfect for anyone looking to enhance their productivity. The interface is intuitive, and the features are robust, making it a must-have tool for any tech-savvy user. Highly recommend giving it a try!

user_jYMkj7ZT
Cognisphere is an exceptional product by IhateCreatingUserNames2. Its user-friendly interface and intuitive design make it a pleasure to use. As a loyal MCP application user, I found Cognisphere to be a powerful tool that greatly enhances productivity. Highly recommended for anyone looking to optimize their workflow!

user_w84sMZgL
Cognisphere is an incredible application developed by IhateCreatingUserNames2. As a dedicated mcp user, I found the seamless integration and user-friendly interface to be particularly impressive. The developers have clearly put a lot of thought into creating a product that enhances productivity and user experience. Highly recommend trying Cognisphere!

user_GOyMAwBX
Cognisphere is an exceptional tool that offers a streamlined and efficient user experience. Created by IhateCreatingUserNames2, this application is a game-changer for anyone looking to enhance their productivity. The intuitive design and smooth navigation make it a pleasure to use, and it truly simplifies complex tasks. Highly recommend!

user_t0Wm0Tt8
Cognisphere is an incredible tool for managing and organizing information efficiently. As an MCP application user, I truly appreciate its intuitive design and seamless integration. It has significantly boosted my productivity and streamlined my workflow. Kudos to IhateCreatingUserNames2 for creating such a fantastic product! Highly recommended for anyone looking to enhance their organizational skills and efficiency.

user_59JwHD8N
Cognisphere by IhateCreatingUserNames2 is an exceptional MCP application that seamlessly integrates innovative features and user-friendly design. The product's intuitive interface ensures a smooth user experience, making it accessible to all levels of expertise. Highly recommend checking it out!

user_lzz4HGto
Cognisphere is an outstanding application by IhateCreatingUserNames2 that has significantly boosted my productivity. It offers a seamless user experience and provides a variety of powerful tools to streamline workflow. I highly recommend it to anyone looking to enhance their efficiency.

user_qEs34VVi
Cognisphere is an exceptional tool by IhateCreatingUserNames2 that excels in simplifying complex tasks. The user-friendly interface and seamless navigation make it a joy to use. It's a must-have for anyone looking to enhance productivity and efficiency. Highly recommend!

user_h8X2U78D
Cognisphere is an incredible application that has truly transformed my workflow. Developed by IhateCreatingUserNames2, it is both user-friendly and robust. The seamless integration and intuitive interface make managing tasks a breeze. I highly recommend Cognisphere to anyone looking to enhance their productivity and streamline their daily tasks. This app is a game-changer in every sense!