fix: exclude thinking traces from summaries, use ephemeral session ID

- Omit Thinking/RedactedThinking from format_conversation() so
  chain-of-thought never leaks into summarization input
- Use ephemeral session ID (summary_{id}) for provider.complete()
  so providers that track context by session ID don't pollute
  historical sessions

Signed-off-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
Michael Neale
2026-04-20 13:19:42 +10:00
parent 429f99f665
commit e843871542
+8 -3
View File
@@ -69,8 +69,9 @@ pub fn format_conversation(conversation: &Conversation) -> String {
};
parts.push(format!("[TOOL]: {}", text));
}
MessageContent::Thinking(t) => {
parts.push(format!("[THINKING]: {}", t.thinking));
MessageContent::Thinking(_) | MessageContent::RedactedThinking(_) => {
// Thinking traces are internal chain-of-thought, never user-visible.
// Exclude from summarization input.
}
_ => {}
}
@@ -174,10 +175,14 @@ async fn summarize_single_session(
let messages = vec![Message::user().with_text(user_prompt)];
// Use a throwaway session ID so providers that track context by session
// (Claude Code, Gemini CLI) don't pollute the historical session.
let ephemeral_id = format!("summary_{}", session_id);
match provider
.complete(
model_config,
session_id,
&ephemeral_id,
SUMMARIZE_SYSTEM_PROMPT,
&messages,
&[],