Skip to content

fix: land multi-agent session path fix + regressions (#15103)#15448

Merged
steipete merged 1 commit into
mainfrom
codex/land-15103-20260213141641
Feb 13, 2026
Merged

fix: land multi-agent session path fix + regressions (#15103)#15448
steipete merged 1 commit into
mainfrom
codex/land-15103-20260213141641

Conversation

@steipete

@steipete steipete commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up landing for closed #15103.

What this includes:

  • Rebased session-path agentId fixes onto current main.
  • Regression tests for multi-agent/non-main transcript path resolution.
  • Changelog note with contributor credit.

Co-authored-by: Josh Lehman [email protected]
Thanks @jalehman.

Greptile Overview

Greptile Summary

This PR primarily threads agentId through 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 for agent:<id>:<sessionId> keys.

One behavioral change in src/auto-reply/status.ts is that /status context usage now uses totalTokens (or input+output) directly instead of respecting the totalTokensFresh flag, which can cause stale/legacy cached totals to be displayed as if they were current.

Confidence Score: 4/5

  • Mostly safe to merge, but there is a correctness regression in /status token reporting semantics.
  • The agentId plumbing and added tests look coherent and targeted, but buildStatusMessage now ignores the existing totalTokensFresh staleness signal and will display stale cached totals as real context usage for affected sessions.
  • src/auto-reply/status.ts

Last reviewed commit: d2c66cf

@cursor

cursor Bot commented Feb 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches session transcript path resolution and usage reporting across auto-reply and gateway APIs; mistakes could break status/usage visibility or accidentally point at the wrong agent’s session files.

Overview
Fixes multi-agent session transcript path resolution by consistently threading agentId through /status output, /usage cost, gateway sessions.usage (including timeseries and logs), and the underlying session cost/usage helpers so non-default agents can read absolute session files without failing path validation.

Updates auto-reply session initialization to pass agentId when forking session logs, and adjusts status token accounting to derive totalTokens directly (removing the stale “freshness” flag behavior). Adds regression tests covering non-main agent transcript usage/cost/timeseries/log retrieval, and documents the fix in CHANGELOG.md.

Written by Cursor Bugbot for commit d2c66cf. This will update automatically on new commits. Configure here.

@steipete
steipete merged commit 9904135 into main Feb 13, 2026
12 checks passed
@steipete
steipete deleted the codex/land-15103-20260213141641 branch February 13, 2026 13:17
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Feb 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread src/auto-reply/status.ts
let inputTokens = entry?.inputTokens;
let outputTokens = entry?.outputTokens;
let totalTokens = resolveFreshSessionTotalTokens(entry);
let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Fix in Cursor Fix in Web

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

src/auto-reply/status.ts
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).

Prompt To Fix With AI
This 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.

skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
@vincentkoc vincentkoc added the dedupe:parent Primary canonical item in dedupe cluster label Feb 23, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…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
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…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
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling dedupe:parent Primary canonical item in dedupe cluster gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants