Skip to main content

build_context

Function build_context 

Source
pub fn build_context(entries: &[SessionEntry]) -> Vec<Message>
Expand description

Builds the LLM context from a session’s entry log.

With no SessionEntry::Compaction entry, returns all Message entries’ messages in append order.

Otherwise the last Compaction entry wins: the result starts with a user message whose text is "[Conversation summary]\n" followed by the compaction’s summary, then contains every Message entry from the one whose entry id equals first_kept_id through the end of the log. If no Message entry matches first_kept_id, the summary message is instead followed by all Message entries positioned after that Compaction entry.

Entries before the cut are dropped from the returned context only — the store keeps the full history (invariant 2 of the module docs).