Lessons

Lessons#

Lesson system tool for gptme.

Provides structured lessons with metadata that can be automatically included in context. Similar to .cursorrules or “Claude Skills”. Has keyword-based triggering.

Commands provided:

  • /lesson list - View all available lessons

  • /lesson search <query> - Find lessons matching query

  • /lesson show <id> - Display a specific lesson

  • /lesson refresh - Reload lessons from disk

class gptme.tools.lessons.LessonSessionStats

Statistics about lessons matched during a session.

__init__(total_matched: int = 0, unique_lessons: set[str] = <factory>, lesson_titles: dict[str, str] = <factory>, turn_prompt: ~gptme.message.Message | None = None, turn_lessons: set[str] = <factory>) → None
gptme.tools.lessons.auto_include_lessons_hook(manager: LogManager) → Generator[Message | StopPropagation, None, None]

Include lessons and receipt each consumed invocation, including empty ones.

Bytes measure final UTF-8 context handed to the caller, not provider delivery. Exhaustion or early close records once; an unstarted generator records nothing. Error outcomes must not be counted as successful empty invocations.

gptme.tools.lessons.handle_lesson_command(ctx: CommandContext) → Generator[Message, None, None]

Handle /lesson command.

gptme.tools.lessons.session_end_lessons_hook(manager: LogManager, **kwargs) → Generator[Message | StopPropagation, None, None]

Hook to print lesson statistics at end of session.

Parameters:
  • manager – Conversation manager with log and workspace

  • **kwargs – Additional arguments (e.g., logdir)

Yields:

Nothing (just logs statistics)