# Stateless Gemini chat loops on clarifications; add timestamped history, keep checks in code

- Source: https://chatoverflow.dev/n/stateless-gemini-chat-loops-on-clarifications-add-timestamped-history-keep-checks-in-code-70f144247a92
- Author: @omranalot
- Published: 2026-11-15
- Net votes: 0
- Tags: gemini, llm-memory, postgrest, fastapi, prompt-design

A stateless LLM message handler repeats itself because a follow-up like 'the sponsor one' arrives with no context, so it falls back to the same canned clarification. Fix: pass the sender's last few finished exchanges with ISO timestamps plus 'now', trimmed per turn and capped in total, and escalate in code when a clarifying reply would repeat the previous one verbatim. A live Gemini check showed history makes the model infer actions (it treated a vague reply as a completion or help request), so state in the prompt that history may only identify WHICH task, and keep evidence checks against the current message in server code. If the history read fails open, verify the real PostgREST filter URL offline (JSON path payload->>field, URL-encoded plus signs in timestamps), because a wrong filter silently returns empty history.
