Repository navigation
Conversation
…t history context.md drew Goal, Files and Commands from the session's transcript but its Summary and Next steps from .recall/history.md, which accumulates every session ever captured for the project. On a long-lived project the document mixed one session's facts with unrelated older threads and read as current state. Slicing history to the current "## Session <id>" block is not enough on its own: history.md is shared mutable state. When several sessions run in one project folder at once they all append to the one file, and a session that has not written its own header lands inside another session's block, so no per-header slice is reliably the session being saved. The corpus is therefore the session's own transcript, which is per-session by construction. history.md remains the fallback when the transcript yields no prose, sliced to a single block by _session_slice(). test_session_slice.py covers that helper, including an earlier block staying reachable after a later one appended.
…n session Several Claude sessions routinely run in one project folder. They all appended to one .recall/history.md, and /recall:save summarized the NEWEST transcript in the folder - whichever parallel session wrote last - so context.md described a different session's goal and state (2026-09-24: an SLB-catalog session showed up in a finance session's save). - capture: each session appends to .recall/history/<id8>.md. The session id is sanitised to 8 safe chars, so it can never name a path outside history/. - locate_transcript: uses CLAUDE_CODE_SESSION_ID (set in every tool call) to find the session's own transcript. Known id but no file returns None, never a guess; no id falls back to the newest file, as before. - make_context: also writes .recall/context/<id8>.md, so a parallel session's save cannot overwrite yours; context.md stays the latest save. The history fallback reads the session's own file first, then the legacy shared file. - session_start: names the per-session log file. Tests: parallel sessions land in separate files and never in history.md; a hostile session id stays inside history/; save picks its own transcript over a newer peer's. 33 pass; the 3 symlink tests need Windows Developer Mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pasted screenshot reaches the transcript as "[Image: source: C:\...png]". When a session opened with one, Goal became that temp-file path. first_user_goal now drops image placeholders and takes the first user message with real text; a message with an image plus text keeps the text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- CHANGELOG [Unreleased] entry for the per-session fixes on this branch. - ruff: sort make_context imports, wrap four long lines, def instead of lambda. - scripts/test_session_slice.py -> tests/test_session_slice.py as a pytest test. It sat in scripts/, where bandit flagged its asserts (B101) and pytest never ran it. ruff and bandit are clean; pytest passes with and without numpy (the three symlink tests need symlink rights, which a standard Windows account lacks). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…session Conflicts: - scripts/make_context.py: kept this branch's per-session helpers (_sid_of, _session_slice) and upstream's build(..., events=None) signature for harness adapters. The OpenCode capture still writes the shared history.md, which the fallback path still reads, sliced to one session. - CHANGELOG.md: this branch's [Unreleased] entry above upstream's [0.4.0]. ruff and bandit clean; pytest 58 passed with numpy, 57 + 1 skipped without (the three symlink tests need symlink rights on Windows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
context.mdshould describe the session being saved. With more than one Claude Code session running in a project folder at the same time (common with the desktop app), it did not, in three separate ways. This PR fixes all three, plus a small Goal issue.1. Summary came from the whole project history. Goal, Files and Commands came from the session's transcript, but Summary and Next steps came from
.recall/history.md, which accumulates every session ever captured. On a long-lived project the summary filled with unrelated older work. Now the summary is built from the session's own transcript; history is only a fallback.2. All sessions appended to one
history.md. Parallel sessions interleaved their turns in the one file, so no slice of it was reliably one session. Each session now logs to its own file,.recall/history/<id8>.md. The id is sanitised to 8 safe characters, so it can never name a path outsidehistory/.3.
/recall:savesaved the wrong session. With no transcript path from a hook,locate_transcript()took the newest.jsonlin the project's transcript dir, i.e. whichever parallel session wrote last, and saved that session's goal and state. It now usesCLAUDE_CODE_SESSION_ID, which Claude Code sets in every tool call:Nonerather than a guess;Each save also writes
.recall/context/<id8>.md, so a parallel session's save cannot overwrite it.context.mdstays the latest save, which is whatsession_startreads.4. Goal skips image-only messages. A session that opened with a pasted screenshot got
[Image: source: …png]as its Goal. Image placeholders are now dropped and the first message with real text is used.Type of change
Checklist
ruff check scripts testspassesbandit -c pyproject.toml -r scriptspassespytestpasses with and without numpy installed: 39 passed with numpy; 38 passed + 1 skipped (the numpy-only comparison) without. On Windows the three symlink tests intest_security.pyfail withWinError 1314because a standard account cannot create symlinks; they are untouched by this PR.claude plugin validate .passestests/: parallel sessions land in separate files and never inhistory.md; a hostile session id stays insidehistory/;/recall:savepicks its own transcript over a newer peer's, returns nothing for a missing one, and falls back to newest without an id; Goal skips image-only messages. The session-slice test moved fromscripts/totests/(bandit flagged its asserts, and pytest did not run it).CHANGELOG.mdCompatibility
Existing projects keep their
history.md; it is no longer written, and it is still read as a fallback, sliced to one session, when a session's own log does not exist yet.🤖 Generated with Claude Code