Fix context loss: ensure system prompt is always present in LLM context
Replaced `if not session.context:` with a role-based check so the system
message is inserted whenever it is absent — not just for brand-new sessions.

Root cause: backward-compat sessions (context column was empty) had their
context initialised from session.messages, which never contains a system
message. The old check (`if not session.context:`) saw a non-empty list and
skipped the system prompt, so every subsequent request ran without it —
Navi had no persona and no profile instructions.

Also add context_token_count field to Session (follow-up for token counter
fix — persistence wiring comes in next commit).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bdd3786 commit 7b1fa2c02b9e2cab9d318b10b9e4fa1d00b79bf1
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 9 Apr
Showing 2 changed files
View
navi/core/agent.py
View
navi/core/session.py