@@ -387,12 +387,14 @@ def _mode_prompts(self) -> dict[str, str]:
387387 def remember_user_text (self , messages : list ) -> None :
388388 """Remember the last real user message for session-title generation.
389389
390- Skips harness-injected nudges so a title is never generated from
391- "Review the original user request and the Task Completion Rules…".
390+ Skips harness-injected messages (nudges, plan/build-switch
391+ reminders, queued mode prompts — flagged ``injected``) so a
392+ title is never generated from "Review the original user request
393+ and the Task Completion Rules…" or a mode-switch reminder.
392394 """
393395 nudge = config .NUDGE_MESSAGE
394396 for m in reversed (messages ):
395- if m .role == "user" and m .text () != nudge :
397+ if m .role == "user" and not m . injected and m .text () != nudge :
396398 self .store .remember_first_user_message (m .text ())
397399 break
398400
@@ -411,6 +413,13 @@ def generate_session_title(self) -> None:
411413 Mirrors gptel-agent-harness--generate-session-title: one-shot per
412414 session (guarded by store.title / title_pending); on success the
413415 session file is renamed to <title>_<TS>.md.
416+
417+ Reasoning models answer with a reasoning preamble; the client
418+ merges it ahead of the real answer, so it is stripped here or
419+ the first 50 chars of the reasoning would become the session
420+ name. The session temperature is passed so the title request
421+ matches the buffer settings (elisp parity) instead of the API
422+ default.
414423 """
415424 store = self .store
416425 if store .title or store .title_pending :
@@ -425,9 +434,18 @@ def generate_session_title(self) -> None:
425434
426435 system = read_prompt_file ("title.txt" )
427436 resp , _ = self .client .chat_sync (
428- [Msg (role = "user" , content = first )], system = system
437+ [Msg (role = "user" , content = first )],
438+ system = system ,
439+ temperature = self .temperature ,
429440 )
430441 title = resp .text ()
442+ if resp .reasoning :
443+ r = resp .reasoning
444+ if title .startswith (r ):
445+ title = title [len (r ):]
446+ else :
447+ title = title .replace (r , "" )
448+ title = title .strip ()
431449 if title :
432450 store .apply_title (title )
433451 if self .store .title :
0 commit comments