"""Exact strings the chat agent uses when it has no user-visible final text.

Callers that persist model output outside the chat transcript (e.g. consolidation
or ledger reflection) must treat these as failures, not real content.
"""

from __future__ import annotations

# Kept in sync with agent_loop._ensure_nonempty_assistant_reply
PLACEHOLDER_NO_VISIBLE_REPLY = (
    "I couldn't produce a visible response for that turn. Please try again."
)
PLACEHOLDER_TOOL_FORMAT_GLITCH = (
    "I hit a tool-formatting glitch and couldn't turn the model output into a "
    "normal answer. Please ask again or restate what you need."
)

VISIBILITY_PLACEHOLDER_EXACT: frozenset[str] = frozenset(
    {PLACEHOLDER_NO_VISIBLE_REPLY, PLACEHOLDER_TOOL_FORMAT_GLITCH}
)


def is_visibility_placeholder(text: str | None) -> bool:
    if text is None:
        return False
    return (text or "").strip() in VISIBILITY_PLACEHOLDER_EXACT
