Skip to content

agent: -m with --session is a turn on that session; stats reset no longer re-caches old totals - #641

Merged
FMXExpress merged 2 commits into
mainfrom
claude/pasclaw-desktop-plan-uapzcp
Nov 13, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/pasclaw-desktop-plan-uapzcp

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Two unrelated fixes, one commit each.

1. pasclaw agent -m "..." --session ID (d685bad)

The command sent the model the new prompt alone and then saved that turn's history over the session file. So:

  • The reply was never saved. The loop's history stops one message short of it, and only the history was written.
  • The model did not see the conversation so far.
  • The conversation so far was replaced by the latest question. An interactive session passed to this command lost its transcript.

Three one-shot turns on one session, on main:

Turn Sent to the model Saved afterwards
1 first question first question
2 second question second question
3 third question third question

With this change, turn 3 sends both earlier questions and replies before the third question, and the session holds all six messages.

The one-shot path now runs the turn the way the interactive prompt resumes a session:

  • The stored messages come first, then the prompt.
  • The prompt, tool calls and results, and the reply are added to the transcript.
  • A provider refusal's error text is printed, not saved as a reply, and the question is kept.
  • The session's own prompt is used and saved back. After a compaction that is where the summary lives.
  • The working-state snapshot goes in front of the prompt for the turn only and is brought up to date afterwards.
  • The turn works in the directory the session works in.

Behaviour change: a one-shot launched from a different directory than the session's now runs its tools in the session's directory, as pasclaw resume does.

Unchanged: without --session a one-shot saves nothing. profile bench uses a fresh id per run and is unaffected.

StripWorkingStatePrefix is the interactive path's inline code, moved out so both paths share it.

2. Stats reset and the cached answer (3d8b58f)

Review finding on #640. POST /v1/stats/reset cleared the cached /v1/stats answer, but a /v1/stats request already reading the sessions at that moment stored its pre-reset answer afterwards. The old totals were then served for another five seconds.

  • The cache has a generation that goes up when it is dropped. An answer is stored only if the cache has not been dropped since the request started.
  • The Stats tab draws only its newest request's answer. A poll sent just before the reset could answer after the reset's own refresh and put the old totals back on screen until the next poll.

Tests

  • make test-oneshot-session-e2e (oneshot_session_e2e.py): the real binary against a scripted fake provider — plain replies, a tool call, a 401, a session that works in another directory, a compacting turn. Each of the nine behaviours, reverted alone, fails it.
  • make test-gateway-stats-buckets: an answer from before a cache drop is refused, one from after is kept. Removing the generation check fails it.
  • The Stats tab's ordering was checked in a browser with a held request, not by a committed test: with the check the totals stay at zero, without it the old ones come back.
  • Live run of the one-shot fix: three turns on one session, the second using a tool, the third answerable only from the saved conversation.
  • Full make test passes on FPC 3.2.2. Not built with Delphi.

Generated by Claude Code

…s back

Review finding on #640. POST /v1/stats/reset cleared the cached
/v1/stats answer, but a /v1/stats request already reading the sessions
at that moment stored its pre-reset answer afterwards, and the old
totals were served for another five seconds.

- The cache has a generation that goes up when it is dropped. An answer
  is stored only if the cache has not been dropped since the request
  started (StatsCacheGet / StatsCachePut / StatsCacheDrop).
- The Stats tab draws only the newest request's answer. A poll sent just
  before the reset could answer after the reset's own refresh and put
  the old totals back on screen until the next poll.

Tests: gateway_stats_buckets_tests pins the cache (an answer from before
a drop is refused, one from after is kept); removing the generation
check fails it. The page's ordering was checked in a browser with a held
request: with the check the totals stay at zero, without it the old
ones come back. No committed test for the page.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
… for it

`pasclaw agent -m "..." --session ID` sent the model the new prompt alone
and then saved that turn's history over the session file. So:

- the reply was never saved: the loop's history stops one message short
  of it, and only the history was written;
- the model did not see the conversation so far;
- the conversation so far was replaced by the latest question, whatever
  the session held -- an interactive session passed here lost its
  transcript.

The one-shot path now runs the turn the way the interactive prompt
resumes a session:

- the stored messages come first, then the prompt;
- the prompt, tool calls and results, and the reply are added to the
  transcript; a provider refusal's error text is printed, not saved as a
  reply, and the question is kept;
- the session's own prompt is used and saved back (after a compaction
  the summary lives there), with the working-state snapshot in front of
  it for the turn only and brought up to date afterwards;
- the turn works in the directory the session works in.

Without --session a one-shot still saves nothing. `profile bench` uses a
fresh id per run and is unaffected.

StripWorkingStatePrefix is the interactive path's inline code, moved out
so both paths share it.

Tests: oneshot_session_e2e.py runs the real binary against a scripted
fake provider (plain replies, a tool call, a 401, a compacting turn).
Each of the nine behaviours, reverted alone, fails it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T19:24:46.134213Z d685bad PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@FMXExpress
FMXExpress merged commit 7dd13b7 into main Nov 13, 2026
@FMXExpress FMXExpress mentioned this pull request Nov 13, 2026
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