Skip to content

[Bug]: ACP session/load overwrites a session whose header line is unreadable with a new empty session #205

Backlog

Description

@julianmesa-gitkraken

What happened?

When the first line of a saved session file can't be parsed, ACP session/load returns success and overwrites that file with a brand-new empty session that has a different id. Every earlier entry in the conversation is lost, and the client gets no error.

The session reader skips lines that fail JSON.parse. If the header is among them, it returns no entries, and setSessionFile then calls newSession() and _rewriteFile() on the same path. A damaged line further down is handled safely: it stays on disk and new entries are appended after it. So this only happens when the header line is the damaged one, for example after an interrupted write or a disk-full error.

What did you expect to happen?

session/load should fail with an error naming the unreadable session and leave the file unchanged. It should never replace an existing conversation file with a new session.

Steps to reproduce

  1. Use an isolated HOME. Start auggie --acp, run initialize, session/new with cwd set to /tmp/repro, and send one session/prompt so the session is persisted. The file is ~/.augment/sessions-v2/--tmp-repro--/<id>.jsonl (5 lines in my run).

  2. Truncate only the first line so it is no longer valid JSON:

    F=~/.augment/sessions-v2/--tmp-repro--/<id>.jsonl
    { head -c 60 "$F"; echo; tail -n +2 "$F"; } > "$F.tmp" && mv "$F.tmp" "$F"
  3. Start auggie --acp again and send session/load with {"sessionId":"<id>","cwd":"/tmp/repro","mcpServers":[]}.

  4. The response is a success. Inspect the file: it now holds 3 lines, a new session header with a different id followed by fresh model_change and thinking_level_change entries. The original messages are gone.

Auggie version

1.2.3 (official npm build). Also reproduced on 1.3.0-prerelease.202611271510.

Request ID

N/A, no model request is involved.

Environment details

macOS (darwin arm64), Node 24.22.3, ACP mode.

Anything else we need to know?

Rejecting a session whose header can't be read, instead of starting a new one at the same path, would be enough. Validating every line before overwriting anything would also protect the case where several lines are damaged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions