chatlog_mcp: sharper tool descriptions to stop Gemini halting after list_chats

- list_chats output now ends with an explicit instruction to call
  chatlog_recent / chatlog_since next (Gemini 2.5 Flash tends to answer
  after a single tool call otherwise)
- list_chats description: clarify it only returns metadata, never content
- recent description: marked as PREFERRED for reading actual messages
This commit is contained in:
Homelab Cursor 2026-05-01 12:58:12 +02:00
parent 2fa011fa2a
commit 97c2dae082

View file

@ -68,6 +68,15 @@ def _format_chats(payload: dict) -> str:
f"- {c.get('title') or '(ohne Titel)'} " f"- {c.get('title') or '(ohne Titel)'} "
f"(id={c['chat_id']}, {c['message_count']} Nachrichten)" f"(id={c['chat_id']}, {c['message_count']} Nachrichten)"
) )
lines.append("")
lines.append(
"WICHTIG: Diese Liste enthaelt nur Metadaten (Titel + Anzahl). "
"Um die NACHRICHTEN selbst zu sehen, MUSST du jetzt zwingend einen "
"zweiten Tool-Call machen: chatlog_recent(chat='<titel-substring>') "
"fuer die letzten Nachrichten ODER "
"chatlog_since(chat='<titel-substring>', hours=24) fuer alles seit "
"den letzten 24h. Antworte NICHT bevor du das gemacht hast."
)
return "\n".join(lines) return "\n".join(lines)
@ -127,10 +136,12 @@ TOOLS = [
{ {
"name": "chatlog_list_chats", "name": "chatlog_list_chats",
"description": ( "description": (
"List every Telegram group that the Arakawa Concierge logger " "Returns ONLY the metadata (title, id, message count) of every "
"is currently recording. Returns the chat title, internal id " "Telegram group being recorded. Does NOT contain any messages. "
"and message count. Always call this first when you don't yet " "Use this only when you don't know which group the user means. "
"know which group the user is asking about." "After calling this you MUST make a second call to chatlog_recent "
"or chatlog_since to actually read the messages — the user "
"wants the conversation content, not just chat titles."
), ),
"inputSchema": { "inputSchema": {
"type": "object", "type": "object",
@ -141,10 +152,15 @@ TOOLS = [
{ {
"name": "chatlog_recent", "name": "chatlog_recent",
"description": ( "description": (
"Return the most recent messages of a recorded Telegram group " "PREFERRED tool to actually READ the latest messages of a "
"as a chronological transcript. Use this for questions like " "recorded Telegram group. Returns a chronological transcript "
"'Was wurde zuletzt geschrieben?' or 'Aktueller Stand?'. " "with timestamps, senders and full message bodies. Use this "
"If 'chat' is omitted, returns recent messages across all groups." "for: 'Was wurde heute / zuletzt geschrieben?', 'Aktueller "
"Stand im <Gruppe>-Chat?', 'Was hat <Person> gesagt?'. "
"If you don't know the chat title, call chatlog_list_chats "
"first and then ALWAYS follow up with this tool. "
"If 'chat' is omitted, returns recent messages across all "
"groups (works fine when only one group is recorded)."
), ),
"inputSchema": { "inputSchema": {
"type": "object", "type": "object",