fix(tui): preserve tool metadata in resumed session history

session.resume was building conversation history with only role and
content, stripping tool_call_id, tool_calls, and tool_name. The API
requires tool messages to reference their parent tool_call, so resumed
sessions with tool history would fail with HTTP 500.

Use get_messages_as_conversation() which already preserves the full
message structure including tool metadata and reasoning fields.
This commit is contained in:
jonny 2026-04-11 05:23:44 +00:00
parent cb79018977
commit 57e8d44af8

View file

@ -483,14 +483,13 @@ def _(rid, params: dict) -> dict:
os.environ["HERMES_INTERACTIVE"] = "1"
try:
db.reopen_session(target)
history = db.get_messages_as_conversation(target)
messages = [
{"role": m["role"], "text": m["content"] or ""}
for m in db.get_messages(target)
{"role": m["role"], "text": m.get("content") or ""}
for m in history
if m.get("role") in ("user", "assistant", "tool", "system")
and isinstance(m.get("content"), str)
and (m.get("content") or "").strip()
]
history = [{"role": m["role"], "content": m["text"]} for m in messages]
agent = _make_agent(sid, target, session_id=target)
_init_session(sid, target, agent, history, cols=int(params.get("cols", 80)))
except Exception as e: