Skip to content

fix(agents): preserve session classification - #122697

Merged
steipete merged 1 commit into
mainfrom
steipete/session-classification-truth
Aug 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/session-classification-truth

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

sessions_list discarded the Gateway’s authoritative session classification and re-derived coarse kinds from raw key prefixes. Real session keys are agent-scoped, so main, cron, hook, and node rows such as agent:main:cron:nightly were classified as other; kind-filtered calls could return empty results for sessions that existed.

Why This Change Was Made

The agent tool now carries and projects the prepared Gateway classification instead of parsing keys again:

  • main/global map to model-facing main;
  • group/channel and group/channel threads map to group;
  • cron, hook, and node retain their authoritative kinds;
  • unsupported/background classifications remain other;
  • node keys are classified at the Gateway producer alongside cron and hook.

Raw-key inference is removed. The built-in sessions tool and Gateway are same-version, in-process owners, so no legacy fallback is retained. The existing protocol field is reused; no schema or protocol change is introduced. The separate post-filter pagination issue is intentionally out of scope.

AI-assisted: yes. The owner-boundary repair and actual Gateway-row regression were manually inspected and passed fresh structured autoreview after final rebase.

User Impact

Models can reliably list and filter real agent-scoped main, cron, hook, group, and node sessions instead of silently losing them as other.

Evidence

  • Pre-fix boundary proof projected real agent-scoped main/cron/hook/node rows as other; all four corresponding kind filters returned empty results. Node’s producer classification was also custom.
  • Regression coverage uses actual buildGatewaySessionRow output instead of unrealistic unscoped fixture keys.
  • Focused proof: 92 tests passed across Gateway classification, sessions-list, OpenClaw sessions tools, and sessions-send A2A.
  • Hosted changed gate passed on Testbox tbx_01kzv9z6a4jynjxjm09eewp61r (run).
  • Exact-head CI passed (run).
  • Targeted formatting/lint, typechecks, import-cycle checks, and git diff --check passed.
  • Rebase preserved exact range-diff and stable patch ID 7e3b69363ce7af370c83ca998aad8d7d0d9b8ea8.
  • Fresh complete-branch autoreview: clean.
  • Production +28/−30 (net −2); tests +130/−18.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 12, 2026
@steipete
steipete marked this pull request as ready for review August 12, 2026 15:48
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 12:11 PM ET / 16:11 UTC.

ClawSweeper review

What this changes

The PR carries Gateway session classifications into the built-in sessions-list tool, adds node classification at the Gateway producer, and adds focused regression coverage.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for maintainer landing: current main still re-parses raw keys and can misclassify agent-scoped sessions, while the proposed producer-to-consumer classification flow is correct and has no blocking finding.

Priority: P1
Reviewed head: dc9b0ae60e6abf672441db2ba8c44d3eded1d0d8

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with realistic regression coverage and no blocking correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored internal repair, so the external-contributor proof gate does not apply; the PR body records focused boundary coverage and exact-head CI.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored internal repair, so the external-contributor proof gate does not apply; the PR body records focused boundary coverage and exact-head CI.
Evidence reviewed 7 items Current-main defect: Current main classifies from raw key prefixes and the legacy wire kind, so agent-scoped cron, hook, node, and main keys do not match their intended coarse kinds.
Authoritative owner: Gateway row construction spreads the producer-owned classification into every listed session row, so consuming that fact avoids duplicate key parsing in the tool.
PR projection: The branch maps supported classifications and uses peer kind to retain group and channel threads as group sessions while leaving direct threads as other.
Findings None None.
Security None None.

How this fits together

The Gateway converts stored sessions into rows consumed by built-in agent tools. The sessions-list tool maps those rows to model-visible kinds before applying optional filters.

flowchart LR
  A[Stored sessions] --> B[Gateway session listing]
  B --> C[Authoritative classification]
  C --> D[Sessions-list tool]
  D --> E[Kind filter]
  E --> F[Model-visible sessions]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch behind current main; the local three-way merge has no changed-path conflict, but normal exact-merge and required-check confirmation remains necessary at landing.
Agent review details

Security

None.

PR surface

Source -2, Tests +112. Total +110 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 28 30 -2
Tests 4 130 18 +112
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 158 48 +110

Review metrics

Metric Value Why it matters
Production versus test LOC production +28/-30 (net -2); tests +130/-18 The repair reduces production code while adding owner-boundary regression coverage for five session kinds.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/sessions-helpers.ts, serialized state: src/agents/tools/sessions-list-tool.test.ts, serialized state: src/agents/tools/sessions-list-tool.ts, serialized state: src/gateway/session-classification.test.ts, unknown-data-model-change: src/agents/tools/sessions-helpers.ts, unknown-data-model-change: src/agents/tools/sessions-list-tool.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the single producer-owned classification flow after the normal maintainer merge gates; it removes the duplicate raw-key policy rather than extending it.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the single producer-owned classification flow after the normal maintainer merge gates; it removes the duplicate raw-key policy rather than extending it.

Do we have a high-confidence way to reproduce the issue?

Yes—current source establishes the misclassification path, and the PR’s boundary test constructs real Gateway rows before exercising every affected filter; it was not executed in this read-only review.

Is this the best way to solve the issue?

Yes—the Gateway is already the authoritative classifier, and projecting its recorded fact removes the duplicate parser that loses agent-scoped classifications.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6093e3477d80.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The repaired sessions-list filters can silently omit existing main, cron, hook, and node sessions from an active agent workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored internal repair, so the external-contributor proof gate does not apply; the PR body records focused boundary coverage and exact-head CI.

Evidence

What I checked:

  • Current-main defect: Current main classifies from raw key prefixes and the legacy wire kind, so agent-scoped cron, hook, node, and main keys do not match their intended coarse kinds. (src/agents/tools/sessions-helpers.ts:143, 6093e3477d80)
  • Authoritative owner: Gateway row construction spreads the producer-owned classification into every listed session row, so consuming that fact avoids duplicate key parsing in the tool. (src/gateway/session-utils-row.ts:425, 6093e3477d80)
  • PR projection: The branch maps supported classifications and uses peer kind to retain group and channel threads as group sessions while leaving direct threads as other. (src/agents/tools/sessions-helpers.ts:151, dc9b0ae60e6a)
  • Boundary regression coverage: The new test builds real Gateway rows for agent-scoped main, channel, cron, hook, and node sessions, then checks both projection and every corresponding kind filter. (src/agents/tools/sessions-list-tool.test.ts:86, dc9b0ae60e6a)
  • Feature provenance: The commit that introduced both session classification and the shared session-tool helper is attributed to Peter Steinberger; this PR is a direct follow-up in that area. (src/gateway/session-classification.ts:1, e30df720459b)
  • Merge and validation evidence: The supplied PR body records 92 focused passing tests and exact-head CI; local three-way merge inspection found no conflict in the changed paths. (dc9b0ae60e6a)

Likely related people:

  • steipete: Created the current Gateway classification and session-tool helper in the preceding feature commit, then authored this focused repair. (role: feature owner and recent area contributor; confidence: high; commits: e30df720459b, dc9b0ae60e6a; files: src/gateway/session-classification.ts, src/agents/tools/sessions-helpers.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-12T15:57:49.296Z sha dc9b0ae :: needs maintainer review before merge. :: none

@steipete
steipete merged commit f29d581 into main Aug 12, 2026
197 checks passed
@steipete
steipete deleted the steipete/session-classification-truth branch August 12, 2026 16:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 12, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 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 gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant