fix: land multi-agent session path fix + regressions (#15103)#15448
Conversation
Co-authored-by: Josh Lehman <[email protected]>
PR SummaryMedium Risk Overview Updates auto-reply session initialization to pass Written by Cursor Bugbot for commit d2c66cf. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2c66cff0b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // it as a new session so that thread context (history/starter/fork) is applied. | ||
| const forceNewForThread = Boolean(ctx.IsFirstThreadTurn) && !resetTriggered; | ||
| if (!isNewSession && freshEntry && !forceNewForThread) { | ||
| if (!isNewSession && freshEntry) { |
There was a problem hiding this comment.
Preserve first thread turn as a new session
This branch now resumes any fresh store entry, but first thread turns can already have a freshly written entry because inbound handling pre-records session metadata before initSessionState runs (see Slack prepare.ts setting IsFirstThreadTurn and calling recordInboundSession). In that case, the first message of a new thread is treated as a resumed session, so new-thread setup like parent-session forking/context bootstrap is skipped, producing incorrect thread context on the first reply.
Useful? React with 👍 / 👎.
| let inputTokens = entry?.inputTokens; | ||
| let outputTokens = entry?.outputTokens; | ||
| let totalTokens = resolveFreshSessionTotalTokens(entry); | ||
| let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0); |
There was a problem hiding this comment.
Respect stale token freshness in status context usage
This assignment bypasses totalTokensFresh and always reports totalTokens (or input+output), so sessions marked with totalTokensFresh: false are now shown as having concrete context usage instead of unknown. That regresses status accuracy when only stale snapshots are available, leading /status to report misleading utilization values (including false high/100% usage).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| // it as a new session so that thread context (history/starter/fork) is applied. | ||
| const forceNewForThread = Boolean(ctx.IsFirstThreadTurn) && !resetTriggered; | ||
| if (!isNewSession && freshEntry && !forceNewForThread) { | ||
| if (!isNewSession && freshEntry) { |
There was a problem hiding this comment.
Slack first-thread-turn session logic silently removed
High Severity
The forceNewForThread guard — which forced new-session initialization on the first message in a Slack thread even when a fresh session entry already existed — was removed along with its explanatory comment. IsFirstThreadTurn is still set in the Slack prepare handler and defined in the templating context type, but nothing consumes it now. This means first thread messages in Slack will reuse existing fresh sessions instead of applying thread context (history, starter, fork).
Additional Comments (1)
That makes Prompt To Fix With AIThis is a comment left during a code review.
Path: src/auto-reply/status.ts
Line: 344:351
Comment:
**Stale totals displayed**
`SessionEntry.totalTokensFresh` is used to mark cached `totalTokens` as stale/unknown (see `resolveFreshSessionTotalTokens` in `src/config/sessions/types.ts`). `buildStatusMessage` no longer consults that flag and always uses `entry.totalTokens` (or `input+output`) as the context baseline, so entries with `totalTokensFresh === false` will still show a concrete context usage instead of unknown.
That makes `/status` misleading for any sessions that intentionally set `totalTokensFresh` to false (including legacy entries).
How can I resolve this? If you propose a fix, please make it concise. |
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9904135) # Conflicts: # CHANGELOG.md # src/auto-reply/status.test.ts # src/auto-reply/status.ts
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9904135) # Conflicts: # CHANGELOG.md # src/auto-reply/status.ts # src/infra/session-cost-usage.test.ts # src/infra/session-cost-usage.ts
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>


Follow-up landing for closed #15103.
What this includes:
Co-authored-by: Josh Lehman [email protected]
Thanks @jalehman.
Greptile Overview
Greptile Summary
This PR primarily threads
agentIdthrough status/usage/session-cost transcript path resolution so non-default agents can resolve absolute session transcript files without failing path validation. It also adds regression tests covering status transcript usage and gateway usage APIs foragent:<id>:<sessionId>keys.One behavioral change in
src/auto-reply/status.tsis that/statuscontext usage now usestotalTokens(orinput+output) directly instead of respecting thetotalTokensFreshflag, which can cause stale/legacy cached totals to be displayed as if they were current.Confidence Score: 4/5
buildStatusMessagenow ignores the existingtotalTokensFreshstaleness signal and will display stale cached totals as real context usage for affected sessions.Last reviewed commit: d2c66cf