Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions frontends/continue_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,13 @@ def _current_log_path(pid=None):
return os.path.join(_LOG_DIR, f'model_responses_{pid}.txt')


def _snapshot_current_log(pid=None):
"""Persist current PID log as a standalone recoverable snapshot, then clear it."""
path = _current_log_path(pid)
def _snapshot_current_log(pid=None, agent=None):
"""Persist the active log as a recoverable snapshot, then clear it."""
path = ''
if agent is not None:
path = getattr(agent, 'log_path', '')
if not path:
path = _current_log_path(pid)
if not os.path.isfile(path):
return None
try:
Expand All @@ -351,7 +355,7 @@ def reset_conversation(agent, message='🆕 已开启新对话,当前上下文
agent.abort()
except Exception:
pass
_snapshot_current_log()
_snapshot_current_log(agent=agent)
if hasattr(agent, 'history'):
agent.history = []
for client in _agent_clients(agent):
Expand Down