Repository navigation
Do not register a stem when probing a session in the in-memory locator - #576
Conversation
Update the vendored tinyinference and tinytools submodule pointers to their latest revisions. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…sors Add tests asserting that probing for the head generation leaves no reserved successor behind, and that a generation begun explicitly stays reserved so a second begin attempt fails. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinytools and tinyinference submodules to their latest commits. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The in-memory locator inherited the trait default for read_session_transcript, which probes through open_stem and leaves an empty handle behind for every generation queried, causing begin_generation to see its own successor as already existing. It now performs a read-only lookup that only returns a transcript when one has actually been written. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): Do not register a stem when probing a session in the in-memory locator. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changed`InMemoryTranscriptLocator` gains an override of `read_session_transcript` at `crates/tinyagents-session/src/port/memory/mod.rs#impl TranscriptLocator for InMemoryTranscriptLocator {` that derives the stem from `SessionRef`, looks up an existing entry under the lock without calling `open_stem`, and returns a handle only when `read_session` yields a written transcript, falling through to `None` otherwise. Because `session_exists`, `head_generation` and `session_chain` all route through that method, every probe stops creating state, and `begin_generation_locked` no longer finds its own successor already present. Reserved-generation semantics are unchanged: `begin_generation` still records the successor in `reserved_generations`. The public API is unchanged. Features
Tests
FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Transcript lookup and generation probes crates/tinyagents-session/src/port/memory/mod.rs, crates/tinyagents-session/src/port/memory/mod_tests.rs |
The locator returns history only for a registered stem with a written session. Tests verify that probing a successor does not create it, and that a begun but unwritten generation remains reserved. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related PRs
- tinyhumansai/tinyagents#573: Adds
Session::reset_history, which creates and writes a successor transcript generation. Both changes involve successor-generation behavior.
Merge Risk: 
Minimal · up to 28b21
-
The supplied change context identifies no issue that needs resolution before merging.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
A rabbit checks the session trail,
Finds written pages by their stem.
It probes ahead; no new page grows,
A reserved leaf stays held in place.
Then hops away with notes in tow.
Comment @coderabbitai help to get the list of available commands.
Summary
InMemoryTranscriptLocatoranswered "does this session exist?" by registering an empty, unwritten stem for the generation it probed. TheTranscriptLocator::read_session_transcriptdefault probes throughopen_stem, which binds a handle whether or not anything was ever written.head_generationwalks the successor chain throughsession_exists, so resolving the head of a session probed (and so registered) the next generation, g1. If the same turn then began that generation (begin_generation_from_baseline, e.g. refreshing a changed system prompt on resume),begin_generation_lockedfound the g1 stem and failed withsession generation already exists or is reserved.Persistent locators count only written records and were not affected; this only hit the in-memory store (tests, deployments with no database).
Cause and fix
An existence probe must not create state.
InMemoryTranscriptLocatornow overridesread_session_transcriptwith an exact lookup that never registers a stem and reports a transcript only when it has been written, which is the contract documented on the trait and what the persistent locators already do.session_exists,head_generationandsession_chainall go through it, so every probe is fixed at once.Reserved-generation semantics are unchanged:
begin_generationstill records its successor inreserved_generations, so a second begin for the same generation is still refused while the first is unwritten or dropped. That is pinned by the existingan_unwritten_successor_is_reserved_until_written_or_droppedand by a new test that probes a begun, unwritten generation and checks it is still reserved.Tests
New in
crates/tinyagents-session/src/port/memory/mod_tests.rs:probing_for_the_head_generation_does_not_reserve_the_next_one(fails before the fix withsession generation already exists or is reserved)a_begun_generation_stays_reserved_after_probing_for_itCommands run:
cargo test -p tinyagents-session(529 + 1 passing)cargo test --workspace(green)cargo fmt --checkcargo clippy --workspace --all-targets -- -D warningsAPI / behavior changes
None to the public API. In-memory
read_session_transcript,session_existsandhead_generationno longer leave an empty stem behind.Note: the branch also carries a pair of checkpoint commits that moved and then restored the
vendor/tinytoolsandvendor/tinyinferencegitlinks; the net diff against main is the two files above only.Summary by CodeRabbit