Skip to content

Autosave interrupted interactive sessions#312

Open
nhicks00 wants to merge 1 commit intompfaffenberger:mainfrom
nhicks00:autosave-interrupted-sessions
Open

Autosave interrupted interactive sessions#312
nhicks00 wants to merge 1 commit intompfaffenberger:mainfrom
nhicks00:autosave-interrupted-sessions

Conversation

@nhicks00
Copy link
Copy Markdown
Collaborator

Summary

Fixes autosave persistence for interrupted Code Puppy sessions.

If a user cancels an agent run with Ctrl-C and then exits, the interactive loop previously skipped the normal autosave path because cancelled runs return None and immediately continue to the next prompt. That could leave the autosave file missing the latest in-memory conversation history.

What Changed

  • Adds a small _save_autosave_snapshot() helper around auto_save_session_if_enabled().
  • Saves immediately before returning to the prompt after a cancelled agent run.
  • Saves once during CLI shutdown so Ctrl-D, /exit, top-level interrupt, or process cleanup has a final persistence attempt.
  • Saves from single-prompt mode in finally as a defensive cleanup path.
  • Adds test coverage for the cancelled interactive prompt path.

Validation

uv run pytest --no-cov tests/test_cli_runner_coverage.py tests/test_cli_runner_full_coverage.py -q
uv run ruff check code_puppy/cli_runner.py tests/test_cli_runner_full_coverage.py
uv run ruff format --check code_puppy/cli_runner.py tests/test_cli_runner_full_coverage.py

Results:

  • 73 passed
  • Ruff check passed
  • Ruff format check passed

@nhicks00 nhicks00 requested a review from mpfaffenberger April 30, 2026 03:44
@mpfaffenberger mpfaffenberger marked this pull request as ready for review May 2, 2026 12:09
@mpfaffenberger
Copy link
Copy Markdown
Owner

This looks straightforward - merge?

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.

2 participants