Skip to content

fix(continue): snapshot the active log on reset - #796

Open
OT-WuLong wants to merge 1 commit into
lsdefine:mainfrom
OT-WuLong:fix/issue-687-log-snapshot
Open

fix(continue): snapshot the active log on reset#796
OT-WuLong wants to merge 1 commit into
lsdefine:mainfrom
OT-WuLong:fix/issue-687-log-snapshot

Conversation

@OT-WuLong

Copy link
Copy Markdown

Summary

  • snapshot the agent's actual active log before resetting a conversation
  • preserve the PID-based path as a fallback for legacy callers
  • respect log_path=False when logging is disabled
  • add regression coverage for active logs, disabled logging, and legacy PID callers

Closes #687.

How This Was Found

#687 pointed out that session logs use three different path-generation strategies.

Tracing the current main branch showed that GenericAgent.log_path uses a random six-digit ID, while _snapshot_current_log() still looked for a PID-based filename. A temporary-directory reproduction calling the real reset_conversation() consistently produced this result:

  • in-memory history was cleared
  • the actual active log remained unchanged
  • no snapshot was created

As a control, resolving the snapshot path to the agent's real log immediately made the log clear and the snapshot appear, confirming that the path mismatch was the root cause.

A later search of historical PRs found #552, which had identified the same issue but was closed after an upstream history rewrite polluted its diff.

Root Cause

GenericAgent writes each session to a randomly generated six-digit log path, while _snapshot_current_log() derived the current log path from the process PID.

As a result, /new and /continue could clear the in-memory history without snapshotting or clearing the agent's actual active log.

Fix

reset_conversation() now passes agent.log_path to _snapshot_current_log(). The existing PID lookup remains available when no explicit path is provided.

An explicit False value continues to mean logging is disabled and will not fall back to or modify a PID-based log.

Validation

Prior Work

This is a clean re-roll of the focused fix originally proposed by @AiHyo in #552. That PR was closed after an upstream history rewrite caused it to include hundreds of unrelated changes. This version is rebuilt directly on the current main and includes focused regression tests.

Agents write to a random log ID, while reset used the PID-derived fallback. Pass agent.log_path, preserve legacy PID callers, and treat False as logging disabled. Reimplements the focused fix from lsdefine#552 on current main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

About difference log_path

1 participant