Skip to content

Commit

Permalink
Only clean up chat log if it was stored (home-assistant#137399)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Feb 5, 2025
1 parent eded99a commit 417a595
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions homeassistant/components/conversation/chat_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ def async_get_chat_log(
else:
history = ChatLog(hass, session.conversation_id)

@callback
def do_cleanup() -> None:
"""Handle cleanup."""
all_history.pop(session.conversation_id)

session.async_on_cleanup(do_cleanup)

if user_input is not None:
history.async_add_user_content(UserContent(content=user_input.text))

Expand All @@ -63,6 +56,15 @@ def do_cleanup() -> None:
)
return

if session.conversation_id not in all_history:

@callback
def do_cleanup() -> None:
"""Handle cleanup."""
all_history.pop(session.conversation_id)

session.async_on_cleanup(do_cleanup)

all_history[session.conversation_id] = history


Expand Down

0 comments on commit 417a595

Please sign in to comment.