Inspiration

I started from a notebook idea: an agent structured like human cognition, with a Brain, an Internal State and an External State. It would be pretrained generically, then “raised” by the one person it serves, like a dog raised by its owner. Every interaction is a state-change event written into one unified memory, and that history is the personalization. Companio is that idea made real, built on Gemini and Google’s Agent Development Kit.

What it does

Companio remembers you specifically. Every fact carries a Beta(alpha, beta) belief, so it tracks both how confident it is and how much evidence backs that confidence. It learns from real feedback when to ask and when to just answer. It never silently overwrites a contradiction; it stages surprising updates for you to confirm. It also turns messy real data (a WhatsApp export) into searchable, anonymized domain knowledge, and it runs with zero setup on a built-in stub or on real Gemini.

It ships as a real app, not just a CLI. A browser chat interface (FastAPI plus a single-page UI) wraps the same Companion core. A live sidebar shows the profile it’s building, the 3-source memory feed and adaptation metrics as I talk to it. Facts waiting for confirmation can be accepted or kept with one click. Past chats are separate, clickable conversation threads that survive a page reload. Both the web app and the CLI accept image attachments. With a Gemini key set, the image goes to the model as a real multimodal input, so it actually sees it.

The same framework drives three domains with no changes to the core: general (no fixed vertical), study (built partly from the real chat data) and fitness (coaching).

How I built it

Five sub-agents run the loop:

Clarifier: decides ask vs. act. Retriever: pulls semantic, episodic and domain knowledge. Guide: writes the response. Feedback: captures explicit and implicit signals. Consolidator: updates beliefs.

The Clarifier scores p = σ(bias + w · features) and also checks entropy. A per-user AdaptiveGate, reused from my Prompt-Action-Asset model, forces a question when a turn deviates sharply from that person’s own baseline. Feedback trains the policy with a REINFORCE-style gradient step.

Everything writes through one shared, source-tagged SQLite store (human, agent and model), so a profile survives across sessions. A privacy layer redacts emails, phone numbers and card numbers before anything is stored.

Generation goes through a real google.adk.Agent and Runner. If ADK isn’t installed it falls back to the raw google-genai SDK, and to the stub if there’s no key. On startup, the app logs which backend it actually picked.

The Bayesian math (Beta, KL divergence) is built from scratch on the Python standard library, with no scipy.

The WhatsApp pipeline:

Parses the export into messages. Redacts PII. Splits it into chunks wherever the chat goes quiet for 45 minutes. Anonymizes every name to a consistent Student NN alias. Safety-filters explicit content.

That gives 43 chunks, of which 31 ship as domain knowledge. Every chunk stays traceable in a JSONL file.

Challenges I ran into

I hit a live 404 from a deprecated Gemini model name. I also had to check ADK’s real API by installing the actual package rather than trusting training data. Anonymizing the chat data took two passes: the first caught sender names, the second caught first names buried in message text.

Most of the hard bugs only appeared when I used the real app:

Corrections hurt learning. Corrections were leaking a false negative reward into the ask-vs-act learning. Profile facts went missing. An over-aggressive entropy check silently discarded profile facts the app had already retrieved. The general domain never stopped asking. It asked the same clarifying question forever. With no knowledge base, the retrieval score defaulted to 0.5, which pinned confidence at 0.525. That sat exactly in the entropy trap (0.998 > 0.99), so it asked no matter what you typed. The gate fired too early. The AdaptiveGate forced a question on a user’s second-ever message. It judged “deviation” against a single thin greeting. It now needs at least two observations before it can fire. Answers didn’t count as answers. Replying to a clarifying question didn’t count as answering it. “strength” isn’t the literal word “goal”, so the fitness domain asked “what’s your goal?” again and again. A reply right after a question is now credited as the answer.

Each fix has a regression test that fails on the old behavior.

Accomplishments that I’m proud of A confidence model where contradiction handling scales automatically with how much evidence a belief already has, with no tuning constant needed. An ask-vs-act policy that provably learns: a test shows its score changes after a single piece of feedback. A real, messy dataset run through real anonymization and safety filtering, not a synthetic stand-in. A full web app with persistent conversation threads and image input on top of the core loop, verified end to end with real Gemini responses, not just the stub. 37 passing tests across the loop, memory, privacy, belief math, ingestion and learning. Four more backend tests run when the Google packages are installed. What I learned

“The agent adapts” only becomes a real claim once it’s a number you can point to: clarifying_rate trending down and profile_influence_rate trending up across sessions, not just a description of intent. Checking an SDK against the actual installed package, not memory, is worth it every time an API can move underneath you. And unit tests don’t catch everything. The worst bugs (stuck questions, the over-eager gate) only appeared when I used the app the way a real person would.

What’s next for Companio Cloud deployment. Deploy to Cloud Run with Firestore as the memory backend. Persistence is already isolated behind one interface, so this touches a single file. Learning from ordinary conversation. This is the biggest gap. Right now growth needs an explicit signal (a rating or a correction), and ordinary conversation isn’t yet mined for facts. Tuning against real data. Tune the surprise threshold and the Clarifier’s decision boundaries against real interaction logs instead of hand-picked defaults.

Built With

Share this project:

Updates

Submission history