fix(state): include finish_reason in conversation replay
SELECT in get_messages_as_conversation() was missing finish_reason, so assistant messages round-tripped through replay (including /branch copies) silently dropped the provider's stop signal. Adds it to the SELECT, restores it on assistant rows, and locks it in with a round-trip test.
This commit is contained in:
parent
7ba1a2b3df
commit
a94841eaa0
2 changed files with 25 additions and 2 deletions
|
|
@ -1464,8 +1464,8 @@ class SessionDB:
|
|||
placeholders = ",".join("?" for _ in session_ids)
|
||||
rows = self._conn.execute(
|
||||
"SELECT role, content, tool_call_id, tool_calls, tool_name, "
|
||||
"reasoning, reasoning_content, reasoning_details, codex_reasoning_items, "
|
||||
"codex_message_items "
|
||||
"finish_reason, reasoning, reasoning_content, reasoning_details, "
|
||||
"codex_reasoning_items, codex_message_items "
|
||||
f"FROM messages WHERE session_id IN ({placeholders}) ORDER BY timestamp, id",
|
||||
tuple(session_ids),
|
||||
).fetchall()
|
||||
|
|
@ -1490,6 +1490,8 @@ class SessionDB:
|
|||
# that replay reasoning (OpenRouter, OpenAI, Nous) receive
|
||||
# coherent multi-turn reasoning context.
|
||||
if row["role"] == "assistant":
|
||||
if row["finish_reason"]:
|
||||
msg["finish_reason"] = row["finish_reason"]
|
||||
if row["reasoning"]:
|
||||
msg["reasoning"] = row["reasoning"]
|
||||
if row["reasoning_content"] is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue