# Next Session: Fix Annie's Time Awareness + Turn-Taking Patience

## What
Two user-reported bugs: (1) Annie says "enjoy your evening" at 11 AM because she has no time context in her system prompt, (2) Annie cuts off Rajesh mid-speech because VAD/silence thresholds are too aggressive. Plan has been adversarially reviewed (4 CRITICAL + 4 HIGH findings, all addressed).

## Plan
`~/.claude/plans/happy-honking-flurry.md`

Read the plan first — it has the full implementation, all review findings, and design decisions.

## Key Design Decisions (from adversarial review)

1. **Per-turn time for phone, per-build for text/voice**: Time is injected in `prompt_builder.build()` (all channels), PLUS refreshed per-turn in `phone_loop.py` for long calls. Voice WebRTC sessions average 5-15 min — acceptable staleness for V1.
2. **`ZoneInfo("Asia/Kolkata")`** — matches `session_broker.py` pattern (NOT manual offset like `proactive_pulse.py`). Only one new function, not a fourth IST copy.
3. **`None` sentinel defaults** for `phone_audio.collect_utterance()` — resolves `os.getenv()` inside function body, not in default args (import-time evaluation bug).
4. **Fix ALL 3 `SileroVADAnalyzer` instances** — bot.py:747, server.py:396, server.py:467 (original plan missed server.py).
5. **`VADParams` from `pipecat.audio.vad.vad_analyzer`** — NOT from `silero` module.
6. **Keep `min_volume=0.6`** (library default) — reviewer caught that lowering it increases false positives.
7. **`max_speech_s=20`** (not 30) — compromise: +5s for stories, still guards DTMF/hold music.
8. **Barge-in fix at call site** (`phone_loop.py:673`) — the function default was dead code because call site hardcodes `threshold_frames=20`.

## Files to Modify (in order)

1. `services/annie-voice/prompt_builder.py` — Add `_IST`, `_current_time_context()`, inject in `build()` after USER section
2. `services/annie-voice/bot.py` — Import `VADParams`, add `_VAD_PARAMS` module config, use in transport_params lambda
3. `services/annie-voice/server.py` — Same VADParams config, fix BOTH instances (line ~396 and ~467)
4. `services/annie-voice/phone_audio.py` — `None` sentinel defaults in `collect_utterance()`, resolve in body
5. `services/annie-voice/phone_loop.py` — Per-turn time refresh (~line 1280) + configurable `_BARGEIN_FRAMES` at call site (~line 670)
6. `services/annie-voice/.env.example` — Document all new env vars with per-machine notes
7. `services/annie-voice/tests/test_prompt_builder.py` — Tests for `_current_time_context()`

## Start Command
```
cat ~/.claude/plans/happy-honking-flurry.md
```
Then implement the plan. All adversarial findings are already addressed in it.

## Verification
1. `cd services/annie-voice && python -m pytest tests/ -x -q` — all 2709+ tests must pass
2. New tests for `_current_time_context()` (IST, part-of-day, format)
3. Deploy Titan (voice): git pull + clear pyc + stop.sh/start.sh from laptop
4. Deploy Panda (phone): git pull + clear pyc + restart phone loop
5. Voice E2E: "What time is it?" → correct answer
6. Phone E2E: "Is it morning?" → correct
7. Turn-taking: Speak 10+ seconds with pauses → no interruption
8. Barge-in: Interrupt Annie mid-speech → she stops
