feat(session): persist message IDs, reply threading, and author identity in session history#1709
Draft
dimonb wants to merge 6 commits intosipeed:mainfrom
Draft
feat(session): persist message IDs, reply threading, and author identity in session history#1709dimonb wants to merge 6 commits intosipeed:mainfrom
dimonb wants to merge 6 commits intosipeed:mainfrom
Conversation
Contributor
Author
|
Hi, guys. The idea of this PR is to preserve more information in the session history to give the LLM more context to implement threading, reactions, etc. My plan is to gradually submit more PRs to the community to support reactions, more complex history compaction, and other cool features that I’ve implemented in my fork. It’s a little messy right now and needs some improvements in loop.go, so I’ll wait. |
Add MessageID and ReplyToMessageID fields to Message struct so they are persisted in JSONL sessions. Store IDs when saving user messages in the agent loop. Annotate history messages with [msg:#ID] and [reply_to:#PARENT] prefixes in BuildMessages so the LLM can navigate thread structure after restart.
Add MessageSender struct to persist author identity alongside messages
in JSONL session history. This lets the LLM address participants by name
in multi-user conversations (e.g. Telegram group chats).
- Add MessageSender{Username, FirstName, LastName} to protocoltypes
- Add Sender *MessageSender field to Message struct
- Add FirstName/LastName fields to bus.SenderInfo
- Extract FirstName/LastName from Telegram user struct
- Store Sender in user messages saved to session history
SubscribeOutbound blocks until the next outbound message is available or the context is done. Used by cron_test to assert message delivery.
359fcfa to
273ea9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Persists structured metadata alongside messages in JSONL session history so the LLM can navigate thread structure and address participants by name across restarts.
What this adds:
MessageIDandReplyToMessageIDfields onMessageso session history can preserve thread metadata instead of flattening conversations to plain textmessage_idvalues when they are appended to historymessage_idas wellMessageSender{Username, FirstName, LastName}struct — stored alongside user messages so the LLM knows who said what in multi-user chats (e.g. Telegram groups)FirstName/LastNameextracted from Telegram user and stored inbus.SenderInfobus.MessageBus.SubscribeOutboundhelper (blocks until next outbound message or ctx done) — required bycron_test.gowhich was already referencing it🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
MessageID/ReplyToMessageIDin the JSONL store, the LLM cannot reconstruct thread structure after a restart. Without storing assistant delivery IDs, outbound turns still lose their platform identity after restart. WithoutMessageSender, it cannot address participants by name.🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
All existing tests pass (
go test ./...) and lint passes (make lint).☑️ Checklist