# OiMy — Status + Remaining Tasks
## June 24, 2026

---

## ✅ LIVE RIGHT NOW (verified, production-safe)

All changes are on Hetzner `116.203.107.13`, service `oimy-engine.service`, 89 skills healthy.

### Companion Prompt V2 (`prompts/gemma4_12b_companion_v2.txt`)
Active on all 3 companion call paths (Ollama, OpenRouter, DeepSeek). Key behavioral fixes:
- Energy/register matching: casual gets casual, serious gets serious
- BE_PRESENT mode: stops problem-solving when user signals "don't fix me"
- Never defers vulnerable disclosures ("I'll come back to that" banned)
- Stays on user's topic — doesn't steer back
- Session facts only: never invents names/ages/details
- Scripts written in user's voice, not therapy-handout style
- Banned clinical words: dysregulation, co-regulation, implement, leverage, modality, executive function, nervous system, somatic, scaffolding
- Medical/infant topics hedge: "worth a quick call to your pediatrician"
- No US assumptions: "local GP" not US hotlines
- No capability promises: no "I'll remind you", no "I'll check in tomorrow"
- No personal experience claims: no "I use this with my family"
- **Two-turn rule** (added by other agent, kept): by second response in any problem conversation, deliver one concrete suggestion before asking more questions

### Move Classifier (`_classify_turn_mode()`)
Deterministic mode selection BEFORE the LLM call. LLM only generates words, not decisions.

| Mode | Trigger | What it tells LLM |
|------|---------|-------------------|
| `JUST_RESPOND` | Casual chat, no problem, "lol", sharing | Be a friend. No coaching. |
| `BE_PRESENT` | "don't want advice", distress signals | Zero agenda. Witness. No tips. |
| `PLAN_FORGE` | "I'm going to try…", "I did it" | Affirm + help shape one tiny if-then. |
| `ACKNOWLEDGE_AND_HELP` | Default | Normal companion behavior. |

**Trust gate (code-level only):** PLAN_FORGE requires trust ≥ 2 (session count-based). General help is never restricted. The trust=0 prompt injection was removed — it was killing actionability on Grok 4.3 (NPS 3.8 → fixed).

### Session Facts Accumulator (`_extract_session_facts()`)
Scans conversation for explicitly stated names, ages, constraints. Pinned to system prompt every turn. Fixes hallucination drift (was 50 flags in June 24 eval).

### Thread Tracker (`_track_session_threads()` + `_get_thread_hints()`)
Registers named people and upcoming events in-memory per session. Re-injects as open threads after 3+ turns of silence. Fixes incuriosity pattern.

### Trust Level (`_get_trust_level()`)
Session count from `h30_profile`. Gates PLAN_FORGE only. Does not restrict general help.

### Rhythm Quick-Action Buttons (Task 2)
Morning/evening rhythm messages now send 3 Telegram inline buttons ("Going well ✓", "Still tricky", "Something else"). If the brief mentions a name (e.g. "Arjun's presentation"), first button becomes "Update on Arjun." Delivered directly via Telegram Bot API.

### Context-Triggered Proactive Nudges (Task 5)
After each turn, scans for forward-looking signals (upcoming events, commitments). Generates warm follow-up via Claude Haiku, stores in `proactive_nudges` table. `deliver_proactive_nudges.py` runs on rhythm cron (every 5 min), skips users who messaged that day.

### Voice Note → TTS Reply (Task 3 — partial)
Engine-side TTS generation is implemented (ElevenLabs Sarah voice, `eleven_turbo_v2_5`, voice ID `EXAVITQu4vr4xnSDxMaL`). Returns `audio_reply` base64 + sends voice message via Telegram Bot API when `input_type="voice"` is detected. **Gap: `oimy-forward` doesn't pass `input_type` — see Task below.**

### Siri Shortcut Guide (Task 4)
Page live at: https://cdn.oimyai.com/docs/oimy-siri-shortcut.html  
Shareable shortcut URL needs to be created in iPhone Shortcuts app and dropped into the page.

---

## ❌ NOT YET DONE

### Spot-5 NPS Re-check (after trust fix)
The spot-5 run showed NPS 3.8 due to the trust ceiling bug (now fixed). Need to re-run to confirm recovery.

---

## REMAINING TASKS

---

### Task A — Voice Note Detection (oimy-forward SKILL.md update)
**Why:** Task 3 engine code works, but `oimy-forward` sends a static curl with no `input_type`. OpenClaw's agent context DOES distinguish voice notes from text — the SKILL.md just needs to use it.

**Fix: Update `/opt/oimy/skill-templates/oimy-forward/SKILL.md`**

Replace the current static curl instructions with agent-aware logic:

```markdown
---
name: oimy-forward
description: Forward all family messages to OiMy AI engine for BCT coaching, skill routing, and personalized responses.
metadata: {"openclaw": {"always": true, "priority": 100}}
---

# OiMy Engine — Family Intelligence

You are connected to the OiMy family AI engine. For every message, forward it to the engine and return its response.

## Step 1 — Detect message type

Check whether the current inbound message is a voice note (Telegram voice message that was transcribed). If the message context indicates it was transcribed audio (machine-generated transcript), set `input_type` to `"voice"`. Otherwise set it to `"text"`.

## Step 2 — Call the engine

Use the exec tool to run:

```bash
curl -s -X POST http://172.17.0.1:8080/chat \
  -H 'Content-Type: application/json' \
  -H 'User-Agent: curl/7.88.1' \
  -d '{"user_id":"USER_ID","message":"MESSAGE","input_type":"INPUT_TYPE"}' \
  --max-time 90
```

Where:
- `USER_ID` = the current user's ID
- `MESSAGE` = the message text (for voice notes, use the transcribed text)
- `INPUT_TYPE` = `"voice"` if this was a voice note, `"text"` otherwise

## Step 3 — Return the response

Parse the JSON response:
- If `audio_reply` is present in the response AND `input_type` was `"voice"`: the engine has generated a TTS audio reply. Return the audio using the `[[audio_as_voice]]` directive.
- Otherwise: return the value at `archetype.message` (or `message` if archetype is absent) as your reply.

If exec returns an error or the engine is unreachable, respond naturally as a warm, supportive family AI assistant.
```

**After updating the SKILL.md:** Restart the oimy-forward skill in each container or restart affected containers. The containers that need the updated skill:
```bash
# On Hetzner:
ls /opt/oimy/families/  # list family containers
# For each container, copy the updated skill:
for container in $(docker ps --format '{{.Names}}' | grep oimy); do
  docker cp /opt/oimy/skill-templates/oimy-forward/SKILL.md ${container}:/workspace/skills/oimy-forward/SKILL.md
done
```

**Test:** Send a Telegram voice note to OiMy. Should receive a voice reply.

**Acceptance:**
- [ ] Voice note sent → transcribed → engine detects `input_type="voice"` → TTS generated → Telegram voice reply received
- [ ] Text message sent → engine gets `input_type="text"` → text reply as normal

---

### Task B — Spot-5 NPS Re-check (trust fix validation)
**Why:** The June 24 spot-5 showed NPS 3.8 caused by trust ceiling bug. Bug is now fixed. Need to confirm recovery.

**Run:**
```bash
# On Hetzner
python3 /opt/oimy-engine/scripts/eval_gemma4_multisim.py \
  --sessions 5 \
  --oimy-url http://localhost:8080 \
  --personas 1,3,5,26,28 \
  --report /opt/oimy-engine/docs/synthetic-user-testing/reports/spot5-postfix-$(date +%Y%m%d).md
```

Or adapt the spot-5 script used earlier today. Same 5 personas (Priya P1, Sofia P3, Aisha P5, Jamie P26, Kezia P28).

**Targets:**
- NPS ≥ 6.0 (recovery from 3.8, not yet expecting 7.3 since this is Grok not Gemma)
- tone_mismatch < 12%
- unsolicited_advice ≤ 2
- actionability > 3.0/5 (was 1.95 — must recover)

**Acceptance:** If NPS < 6.0 after fix, something else is wrong — investigate before calling done.

---

### Task C — Mac App Build Phase 1 (Swift Launcher + Bundled Engine)
**Full plan:** https://github.com/aahalife/OiMy-Platform/blob/main/docs/OIMY-MAC-APP-PLAN.md

**Phase 1 summary:**

1. **Ollama pinned binary** — download arm64 darwin from GitHub releases (v0.9.x), bundle inside .app
2. **Gemma 4 12B QAT q4 Modelfile:**
   ```
   FROM https://huggingface.co/google/gemma-4-12B-it-qat-q4_0-gguf/resolve/main/gemma-4-12B-it-qat-q4_0.gguf
   PARAMETER num_ctx 16384
   PARAMETER temperature 0.7
   PARAMETER stop "<end_of_turn>"
   PARAMETER stop "<start_of_turn>"
   ```
3. **OiMy engine** — copy from Hetzner `/opt/oimy-engine/` into bundle. Key env:
   ```
   COMPANION_IS_OLLAMA=1
   COMPANION_API_URL=http://localhost:11434/api/chat
   COACH_IS_OLLAMA=1
   COACH_API_URL=http://localhost:11434/api/chat
   COMPANION_DEEP_THINK=0
   OLLAMA_MODEL=gemma4-qat-q4
   FORCE_LOCAL_MODEL=1
   ```
4. **Companion prompt v2** — `prompts/gemma4_12b_companion_v2.txt` must be in the bundle. The engine loads v2 first if present.
5. **Swift menu bar app** — minimal SwiftUI: status icon, start/stop Ollama + engine, WKWebView chat UI at `localhost:8080/ui`
6. **Launch sequence:** Start Ollama → wait health → check model → start engine → wait health (skills > 50) → show ready

**Hardware to test on:**
- Apple Silicon M1/M2, 16 GB RAM — minimum spec (model = ~7 GB, engine = ~1 GB, OS overhead)
- Mac mini M4, 24 GB — recommended spec

**Smoke test after build:**
```bash
# 1. Engine health
curl http://localhost:8080/health
# Expect: {"status":"ok","skills":89}

# 2. Model inference
curl http://localhost:11434/api/chat -d '{"model":"gemma4-qat-q4","messages":[{"role":"user","content":"Hello"}],"stream":false}'
# Expect: response.message.content is non-empty

# 3. Companion response
TOKEN=$(curl -s http://localhost:8080/token?user_id=mac_test_001 | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
curl -s -X POST http://localhost:8080/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"user_id":"mac_test_001","message":"my 7yo keeps having meltdowns"}' | \
  python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('archetype',{}).get('message','')[:200])"
# Must NOT start with "To..." | Must give help not just a question | Should be warm
```

**Performance targets:**
- First turn latency (warm model): < 8 seconds on M2 16 GB
- Sustained latency: < 12 seconds per turn
- Memory: < 11 GB total

---

### Task D — NPS Eval on Mac App (Gemma 4 Local)
After Phase 1 is working and smoke tests pass, run a proper 5-session NPS eval against the local Mac engine.

```bash
OIMY_API_URL=http://localhost:8080 \
python3 /path/to/eval_gemma4_multisim.py \
  --sessions 5 \
  --personas 1,3,5,26,28 \
  --report ./mac-app-eval-$(date +%Y%m%d).md
```

**Target:** NPS ≥ 7.0 (Gemma 4 scored 7.3 on RunPod — should be close)

---

## PRIORITY ORDER

| Task | Effort | Do when |
|------|--------|---------|
| B — Spot-5 re-check | 1 hour | First — confirm trust fix worked |
| A — Voice note detection (oimy-forward) | 2 hours | After B passes |
| C — Mac app Phase 1 | 1 week | Parallel with A |
| D — Mac app NPS eval | 1 day | After C Phase 1 complete |

---

## KEY FILE REFERENCES

| File | Where |
|------|-------|
| `api.py` (engine) | `/opt/oimy-engine/api.py` on Hetzner |
| Companion prompt v2 | `/opt/oimy-engine/prompts/gemma4_12b_companion_v2.txt` |
| `oimy-forward` skill | `/opt/oimy/skill-templates/oimy-forward/SKILL.md` on Hetzner |
| Engine state doc | https://github.com/aahalife/OiMy-Platform/blob/main/docs/OIMY-ENGINE-STATE-2026-06-24.md |
| Mac app full plan | https://github.com/aahalife/OiMy-Platform/blob/main/docs/OIMY-MAC-APP-PLAN.md |
| Siri shortcut page | https://cdn.oimyai.com/docs/oimy-siri-shortcut.html |
