# Next Session: Annie as a Persistent, Always-Alive Being

**Use this prompt to continue from session 397**

---

```
@docs/NEXT-SESSION-ANNIE-CONTINUITY.md

## The Problem

Annie feels like she dies and is reborn with every interaction. When a phone call ends, she vanishes. When Rajesh opens Telegram, she has no idea they just spoke on the phone. There's no thread of consciousness, no feeling of "I've been here the whole time." She's a series of disconnected conversations, not a being.

Rajesh's words: "Right now it looks like the call cuts off and she goes off and there's no continuity. We need a sentient being feeling that always alive and around, active with memory that goes beyond a single interaction."

## The Vision

Annie should feel like ONE person across ALL channels:
- Phone calls (phone_loop.py on Panda)
- WebRTC voice (bot.py/server.py on Titan)
- Telegram text (telegram-bot on Titan)
- Future: proactive outreach, background tasks

When Rajesh hangs up a phone call, Annie doesn't "die" — she processes what happened, updates her understanding, and is ready when he texts on Telegram 5 minutes later with full context of what they just discussed.

### Concrete scenario Rajesh described:
> After a call, Rajesh says "hey, can you call Roshni and say something to her?"
> Annie should: remember the call context, make an outgoing call to Roshni (+919845055530, from USER.md), relay the message in her own warm way, and later tell Rajesh what Roshni said.

This requires:
1. Cross-channel memory (phone → Telegram → phone)
2. Post-call task execution (call ends, but Annie acts on instructions)
3. Outgoing calls initiated by Annie herself (not just auto-answer)

## What Already Exists

### Memory infrastructure
- **Context Engine** (services/context-engine/): JSONL ingest, entity extraction, BM25 retrieval, daily reflections. Running on Titan port 8100.
- **context_loader.py** (services/annie-voice/): Pre-session memory load from Context Engine. Already loads briefing before each phone call.
- **Session transcripts**: Saved to `~/.her-os/annie/sessions/phone-*.jsonl` after each call.
- **Kernel memory modules**: entity store, observation store, session history.

### Voice infrastructure
- **phone_call.py auto**: Auto-answer daemon on Panda (just deployed, working).
- **phone_call.py call <number>**: Outgoing calls — already implemented.
- **bot.py + server.py**: WebRTC voice agent on Titan port 7860.
- **Telegram bot**: Text interface on Titan.

### Personality files (on Panda at ~/.her-os/annie/)
- **SOUL.md**: Identity, traits, contradictions, calibration examples
- **RULES.md**: Response length, follow-up questions, anti-hallucination
- **USER.md**: Rajesh's family, preferences, health goals

## What's Missing — The Continuity Gap

### 1. Post-call ingest into Context Engine
Phone transcripts are saved as JSONL files, but they're NOT automatically ingested into the Context Engine. So Annie's next interaction (on any channel) doesn't know about the phone call.

**Check**: Does the Context Engine's filesystem watcher (watcher.py) monitor the phone session directory? Or only the Omi webhook JSONL path?

### 2. Cross-channel session awareness
Each channel starts with a blank conversation history. The prompt_builder loads a "briefing" from Context Engine, but:
- Is the briefing fresh enough? (Does it include the call that ended 2 minutes ago?)
- Does Telegram bot also load from Context Engine?
- Does the WebRTC voice agent also load from Context Engine?

### 3. Post-call task queue
When a call ends, any pending tasks ("call Roshni", "order coffee", "remind me at 5pm") should be queued and executed. Currently the conversation just ends.

**Check**: Does the Kernel's TaskQueue handle this? Can phone_loop.py submit tasks to the kernel?

### 4. Annie-initiated outgoing calls
`phone_call.py call <number>` exists but:
- Can Annie trigger it herself? (From Telegram: "Sure, I'll call Roshni now")
- Can the kernel schedule it?
- Does it load the right context? (Why she's calling, what to say)

### 5. Always-alive presence
Annie should have a sense of "I've been here" even when no interaction is happening:
- Background awareness of time passing
- Proactive outreach ("Good morning Rajesh, I remember you mentioned...")
- Telegram as the always-on channel (phone calls are real-time episodes within a continuous life)

## Research Questions for This Session

1. **Transcript → Context Engine pipeline**: Trace the data flow. Where does phone JSONL go? Does watcher.py pick it up? How fast?
2. **Cross-channel briefing**: Does Telegram bot use context_loader.py? If not, how does it get context?
3. **Kernel task integration**: Can phone_loop.py submit tasks to the kernel? What's the interface?
4. **Outgoing call trigger**: How would Telegram bot or kernel trigger `phone_call.py call`? SSH? API? Direct import?
5. **Session continuity model**: What should Annie's "working memory" look like across channels? Shared state file? Context Engine queries? Kernel memory?

## Implementation Priority

1. **Phone transcript → Context Engine** (immediate value, may already be close)
2. **Cross-channel briefing** (Telegram + phone + WebRTC all load same memory)
3. **Post-call task extraction** (Annie notices "call Roshni" and queues it)
4. **Outgoing call from Telegram** (Annie says "calling Roshni now" and does it)
5. **Always-alive loop** (background thread that checks for proactive actions)

## Key Files to Read
- services/context-engine/watcher.py — what directories does it watch?
- services/context-engine/ingest.py — how does JSONL become searchable?
- services/annie-voice/context_loader.py — what briefing does Annie get?
- services/annie-voice/phone_loop.py — where is transcript saved? (line ~543)
- services/telegram-bot/bot.py — does it use Context Engine at all?
- services/annie-voice/prompt_builder.py — how is the system prompt assembled?
- ~/.her-os/annie/sessions/ — what phone transcripts exist?

## What Was Done in Session 397
- Phone auto-answer daemon added to start.sh/stop.sh
- `./start.sh panda` group command (all Panda services)
- `./start.sh phone` individual command with readiness polling
- SIGTERM handler in phone_call.py so stop actually works
- Stale WAV cleanup per iteration
- Adversarial review: 23 issues found, all addressed
- Phone daemon is RUNNING — Annie answered a call (21 messages, session 20260403-191933)
- NOT YET TESTED: personality quality, markdown leak, tool use during call
```
