Skip to main content

load_session_messages

Function load_session_messages 

Source
pub fn load_session_messages(session_dir: &Path) -> Result<Vec<ChatMessage>>
Expand description

Load a previously-persisted messages.jsonl and sanitize for resume.

Sanitization:

  • Skip empty lines and malformed JSON (logged + skipped, not fatal).
  • Drop any System messages (the resumed session uses a fresh system prompt).
  • Strip reasoning_content / thinking_signature from Assistant messages.
  • Patch dangling tool calls at the tail: if the last Assistant message has tool_calls that were never answered, synthesize a Tool response with content "interrupted" so that validate_message_sequence passes.