Chats#
List, search, and summarize past conversation logs.
Instructions
### When to use chats
For past conversations, use list_chats() for recent sessions, search_chats(query)
for content, and read_chat(id) for a saved conversation. Search message numbers
pass directly to start_message; full=True recovers bounded multiline text.
Do **not** use chats for:
- The current conversation — its content is already in the context window.
- Searching files or code — use the shell or read tool instead.
- Web or documentation search — use the browser tool.
Examples
Search for a specific topic in past conversations
| User |
Can you find any mentions of "python" in our past conversations? |
| Assistant |
Certainly! I'll search our past conversations for mentions of "python" using the search_chats function. |
- gptme.tools.chats.conversation_stats(since: str | None = None, as_json: bool = False, conversation_id: str | None = None) None
Show statistics about conversation history.
Per-model conversation counts include each conversation once for every model in its usage metadata, so these counts need not sum to the global count. Histories without per-model usage fall back to their last model (or unknown).
- Parameters:
since – Only include conversations since this date (YYYY-MM-DD or Nd).
as_json – Output as JSON instead of formatted text.
conversation_id – Optional conversation ID to inspect in detail.
- gptme.tools.chats.find_empty_conversations(max_messages: int = 1, include_test: bool = False) list[dict]
Find conversations with few or no messages.
Scans all conversations and returns those with at most max_messages messages. Useful for cleaning up abandoned or empty conversation logs.
- Parameters:
max_messages – Maximum message count to consider “empty” (default: 1, system-only).
include_test – Whether to include test/eval conversations.
- Returns:
List of dicts with conversation metadata and disk size.
- gptme.tools.chats.list_chats(max_results: int = 5, metadata=False, include_summary: bool = False) None
List recent chat conversations and optionally summarize them using an LLM.
- gptme.tools.chats.read_chat(id: str, max_results: int = 5, incl_system: bool = False, context_messages: int = 0, start_message: int | None = None, full: bool = False, content_offset: int = 0, max_chars: int = 10000) None
Read a conversation, previewing one line per message unless full=True.
- Parameters:
id – Conversation ID.
max_results – Visible message limit, including context.
incl_system – Show system messages.
context_messages – Visible messages before start_message.
start_message – 1-based original-log position, matching search even with hidden system messages. Defaults to the beginning.
full – Emit verbatim multiline content, capped by max_chars per message.
content_offset – Zero-based character offset; requires full=True, max_results=1 and no context. Follow emitted hints to continue.
max_chars – Full-mode character cap (1..100000).
- gptme.tools.chats.search_chats(query: str, max_results: int = 5, system=False, sort: Literal['date', 'count'] = 'date', context_lines: int = 1, max_matches: int = 1) None
Search past conversation logs for the given query and print a summary of the results.
Displayed message numbers are 1-based original-log positions, including hidden system messages. Pass them directly to read_chat(start_message=…).
- Parameters:
- gptme.tools.chats.search_external_chats(query: str, max_results: int = 5, include_cursor: bool = True, include_codex: bool = True, cursor_dir: Path | None = None, codex_dir: Path | None = None) None
Search external agent sessions (Cursor, Codex) for query.
Prints matching snippets grouped by source agent, with a
[Cursor]or[Codex]label so results are clearly distinguished from gptme native results.- Parameters:
query – The search query (case-insensitive substring match).
max_results – Maximum number of sessions to display.
include_cursor – Whether to search Cursor sessions.
include_codex – Whether to search Codex sessions.
cursor_dir – Override the default Cursor conversations directory.
codex_dir – Override the default Codex sessions directory.