tools.short_term_notes module
Per-channel ephemeral short-term notes (v3)
Notes are stored in a Redis sorted set with configurable TTL. They are internal/secret and auto-injected into context.
- async tools.short_term_notes.store_short_term_note_for_channel(redis_client, channel_id, note_content, ttl_preset='1day', *, merge_key_ttl=False)[source]
Append one short-term note for channel_id using the standard Redis encoding.
Returns
(member_json, note_id)for optional precise removal viaremove_short_term_note_member(), orNonewhen ttl_preset is invalid.
- async tools.short_term_notes.remove_short_term_note_member(redis_client, channel_id, member_json)[source]
Remove one specific short-term note from a channel by its exact member.
Deletes a single note whose canonical JSON string (the value returned alongside the note id by
store_short_term_note_for_channel()) is used as the sorted-set member, enabling precise removal of just that note rather than clearing the channel. If removing it empties the zset, the key is deleted outright so no empty container lingers in Redis.Operates on the channel notes key via the async Redis client (
ZREM, thenZCARDand a conditionalDELETE); no other state is touched. Defined for callers that stored a note and kept the member string for later cleanup; no in-repo callers invoke it directly at present.
- async tools.short_term_notes.format_channel_short_term_notes_for_prompt(redis_client, channel_id)[source]
Render a channel’s live short-term notes as prompt-ready text.
Reads every unexpired note for the channel and formats each one as a
[Short-term Note]:line so the result can be dropped straight into an LLM prompt. Notes with empty or missing content, and members that fail to parse as JSON, are skipped; blocks are separated by blank lines and an empty string is returned when the channel has no notes.Reads the channel notes zset via the async Redis client (
ZRANGEwith scores) and performs no writes. Called bytools.admin_whisper._admin_whisper()to fold any existing channel notes into the secret admin-whisper prompt before the LLM call.