[loop-cycle-40] fix: use get_system_prompt() in cloud backends (#135) (#138)

## What

Cloud backends (Grok, Claude, AirLLM) were importing SYSTEM_PROMPT directly, which is always SYSTEM_PROMPT_LITE and contains unformatted {model_name} and {session_id} placeholders.

## Changes

- backends.py: Replace `from timmy.prompts import SYSTEM_PROMPT` with `from timmy.prompts import get_system_prompt`
- AirLLM: uses `get_system_prompt(tools_enabled=False, session_id="airllm")` (LITE tier, correct)
- Grok: uses `get_system_prompt(tools_enabled=True, session_id="grok")` (FULL tier)
- Claude: uses `get_system_prompt(tools_enabled=True, session_id="claude")` (FULL tier)
- 9 new tests verify formatted model names, correct tier selection, and session_id formatting

## Tests

1508 passed, 0 failed (41 new tests this cycle)

Fixes #135

Co-authored-by: Kimi Agent <kimi@timmy.local>
Reviewed-on: http://localhost:3000/rockachopa/Timmy-time-dashboard/pulls/138
Reviewed-by: rockachopa <alexpaynex@gmail.com>
Co-authored-by: hermes <hermes@timmy.local>
Co-committed-by: hermes <hermes@timmy.local>
This commit is contained in:
2026-03-15 09:44:43 -04:00
committed by rockachopa
parent d48d56ecc0
commit 48c8efb2fb
3 changed files with 191 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ import time
from dataclasses import dataclass
from typing import Literal
from timmy.prompts import SYSTEM_PROMPT
from timmy.prompts import get_system_prompt
logger = logging.getLogger(__name__)
@@ -128,7 +128,7 @@ class TimmyAirLLMAgent:
# ── private helpers ──────────────────────────────────────────────────────
def _build_prompt(self, message: str) -> str:
context = SYSTEM_PROMPT + "\n\n"
context = get_system_prompt(tools_enabled=False, session_id="airllm") + "\n\n"
# Include the last 10 turns (5 exchanges) for continuity.
if self._history:
context += "\n".join(self._history[-10:]) + "\n\n"
@@ -388,7 +388,9 @@ class GrokBackend:
def _build_messages(self, message: str) -> list[dict[str, str]]:
"""Build the messages array for the API call."""
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
messages = [
{"role": "system", "content": get_system_prompt(tools_enabled=True, session_id="grok")}
]
# Include conversation history for context
messages.extend(self._history[-10:])
messages.append({"role": "user", "content": message})
@@ -481,7 +483,7 @@ class ClaudeBackend:
response = client.messages.create(
model=self._model,
max_tokens=1024,
system=SYSTEM_PROMPT,
system=get_system_prompt(tools_enabled=True, session_id="claude"),
messages=messages,
)