Zhang Han
All work

Personal project · AI companion

GouziCode

A local AI companion with memory

An AI companion that remembers conversations and uses journals and mood records in later replies. Memories stay on the local machine, with access through the CLI, macOS app or Telegram. It can also check in about earlier conversations.

On this page
Built
Companion sessions · Memory retrieval · Follow-ups · Client apps
Stack
Python · FastAPI · SQLite · SwiftUI

Remembering earlier conversations

Python AgentSession handles model and tool calls. The server shares memories, journals and temporal analysis. Clients receive replies and approval requests over WebSocket, while a separate scheduler triggers check-ins.

Session · Conversation
Supports Gemini, Anthropic and OpenAI, adding persona settings, relevant memories and temporal context to the conversation. Tool results return to the model. Long conversations can be compacted and their transcripts saved.
Memory · Long-term recall
SQLite stores memories, ranked by relevance, recency and importance. A user summary and related entries fit within a context budget. Users can query and delete memories.
Bridge · Client connection
FastAPI / WebSocket connects the agent thread to the async server, using queues to carry replies. Tools that require approval wait for the client’s response.

Deciding when to check in

Memories are extracted after each turn. Temporal analysis combines journals and mood records to find follow-up topics. Before sending, the scheduler checks quiet hours, the daily message count and recent conversation. Repeatedly ignored check-ins reduce the frequency.

Local storage and clients

The macOS SwiftUI client receives replies and displays approvals; Telegram connects to the same service. Memories live in local SQLite, with journals, mood records and transcripts stored separately. Models and optional embedding services still connect to configured providers.