Skip to content

feat(sessions): organize visible sessions through agent tools - #126146

Closed
vyctorbrzezowski wants to merge 16 commits into
openclaw:brzezowski/session-organize-inheritfrom
vyctorbrzezowski:brzezowski/session-organize-tools
Closed

vyctorbrzezowski wants to merge 16 commits into
openclaw:brzezowski/session-organize-inheritfrom
vyctorbrzezowski:brzezowski/session-organize-tools

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Related: #126064 and #126074
Stacked on #126094.

What Problem This Solves

Current main supports single-session category set/clear, but organizing many matching sessions still requires one model/tool round trip per session and the agent cannot inspect unread, owner, project/worktree-presence, icon, or active status/attention metadata through the focused list output.

Why This Change Was Made

Rebased onto #126074, which owns the single-session category contract. This PR retains only the distinct additions:

  • unread on the existing single-session patch action;
  • patch_many for category/unread updates to at most 100 visible targets;
  • lightweight organization fields in sessions_list without paths or full worktree objects.

The adapter routes directly to canonical sessions.patchMany, preserving current visibility plus snapshot and commit-time authorization. Results are bounded counts plus failures; oversized failure details are omitted under the existing tool-result budget.

User Impact

Agents can inventory organization metadata and update up to 100 visible sessions in one model tool call.

Evidence

All validation ran remotely; no tests, checks, builds, mock servers, or runtime proof ran on the development host.

  • Blacksmith Testbox tbx_01m0brx1kpmqzg3yn9g7fzb71j: 67/67 focused tests passed; 100 category patches completed in 526 ms with one entry-replacement batch and zero full transcript hydration.
  • Blacksmith Testbox tbx_01m0c0dnnvk4jca07nwadyvf4w: touched-file lint passed with 0 findings.
  • Blacksmith Testbox tbx_01m0c3xyypn9c353kf88yrkbw5: rebased stack, 56/56 agent-tool tests and 3/3 batch performance tests passed; 100-session batch completed without transcript hydration.
  • Isolated real Gateway tbx_01m0bskt65cprttppxwhm4t3x3:
{
  "before": null,
  "patch": {"status":"updated","updated":["category"]},
  "afterPatch": "Research",
  "clear": {"status":"updated","updated":["category"]},
  "afterClear": null,
  "authorization": "Session status visibility is restricted to the current session tree"
}

Provenance

The session self-service tool was introduced in e905a682f7a. #126074 supplies the now-current single-category parity. This PR reuses the existing batch Gateway owner for the remaining bulk/unread and organization-projection capability.

Production-vs-test LOC

Production/docs: +258/-8. Tests/test fixtures: +252/-18. No duplicate mutation engine, persistence path, protocol method, config surface, or migration.

@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 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: L maintainer Maintainer-authored PR labels Aug 19, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 24, 2026, 4:59 PM ET / 20:59 UTC.

ClawSweeper review

What this changes

This PR adds batch category/unread updates and additional organization metadata to the agent-facing session tools.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open: the branch adds useful session-organization capability, but it regresses the documented sessions_list contract and retains a duplicate category assignment. The new core model-tool surface also needs explicit maintainer direction.

Priority: P3
Reviewed head: e83f41e7b31d96ee8d6a75043440eaa87f85ead0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation has a coherent owner boundary, but two known branch regressions and unresolved core-surface direction prevent merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports an isolated Gateway check, but this review did not treat that as independent batch-path proof.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports an isolated Gateway check, but this review did not treat that as independent batch-path proof.
Evidence reviewed 7 items Current documentation contract: Current main documents filters, archived selection, preview controls, safety omissions, and restricted-visibility metadata; the proposed replacement omits those established behaviors.
Documentation regression: The changed paragraph reduces the public sessions-list reference to new metadata and lifecycle identity, dropping the current documented filters, previews, and visibility boundary.
Duplicate property remains: The patch object writes the same normalized category field twice; the latter value wins, but this preserves the CodeQL-reported duplicate property.
Findings 2 actionable findings [P2] Restore the full sessions_list contract
[P3] Remove the duplicate category property
Security None None.

How this fits together

Agent session tools turn model requests into visibility-scoped Gateway calls. The Gateway authorizes and commits session-state updates, then the tools return bounded results and session-list projections to the model.

flowchart LR
  A[Model session request] --> B[Agent session tools]
  B --> C[Visible target resolution]
  C --> D[Gateway authorization]
  D --> E[Session mutation engine]
  E --> F[Persisted session state]
  F --> G[Bounded tool result]
Loading

Decision needed

Question Recommendation
Should OpenClaw add a prompt-visible core patch_many action for bulk session organization, rather than retain only single-session mutation and group-catalog controls? Approve bounded core batch organization: Keep the 100-target category/unread action after the documented contract and duplicate write are repaired.

Why: VISION.md treats every core tool and prompt line as a per-call product cost, while the related category request was explicitly awaiting product direction.

Before merge

  • Restore the full sessions_list contract (P2) - Current main documents filters, archived selection, previews, omission boundaries, and restricted-visibility metadata here. Replacing that contract with only the new organization fields silently removes supported usage guidance; extend the existing paragraph instead.
  • Remove the duplicate category property (P3) - category is added twice to the same patch object. The later spread currently wins, but this is the duplicate-property condition already reported by CodeQL and should be deleted.
  • Resolve merge risk (P1) - This exposes a model-visible action that can update category/read state for up to 100 persisted sessions, so core-surface acceptance and an allowed-versus-forbidden batch trace should precede merge.
  • Resolve merge risk (P1) - The Codex prompt-snapshot path depends on the pinned Codex harness, but direct sibling-source inspection was unavailable in this sandbox.

Findings

  • [P2] Restore the full sessions_list contract — docs/concepts/session-tool.md:35
  • [P3] Remove the duplicate category property — src/agents/tools/sessions-tool.ts:518-520
Agent review details

Security

None.

PR surface

Source +244, Tests +290, Docs +1, Other +10. Total +545 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 8 249 5 +244
Tests 9 314 24 +290
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 10 0 +10
Total 19 576 31 +545

Review metrics

Metric Value Why it matters
Production versus test LOC production/docs +262/-7; tests/fixtures +314/-24 Most growth is a new core model-tool and adapter surface, so the retained public contract and product-direction decision matter more than raw test volume.

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/agents/tools/sessions-tool-patch-many.ts, serialized state: src/agents/tools/sessions-tool.organization.test.ts, serialized state: src/agents/tools/sessions-tool.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair the contract before considering merge (recommended)
    Restore the full sessions_list documentation, remove the repeated category field, and provide a redacted allowed/forbidden batch trace.
  2. Pause the new core bulk action
    If maintainers do not want this prompt-visible bulk mutation surface, close the stack without merging the adapter.

Technical review

Best possible solution:

Keep the canonical Gateway batch owner, restore the complete list-tool documentation, remove the duplicate category spread, and land only after maintainers approve the new core model-tool surface.

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

Yes for the review findings: comparing the branch with current main directly reproduces the missing documentation contract and duplicate property. No live batch Gateway run was performed in this read-only review.

Is this the best way to solve the issue?

No: reuse of the existing Gateway batch owner is the right boundary, but the branch must preserve the established list contract and receive an explicit decision on the new core tool surface.

Full review comments:

  • [P2] Restore the full sessions_list contract — docs/concepts/session-tool.md:35
    Current main documents filters, archived selection, previews, omission boundaries, and restricted-visibility metadata here. Replacing that contract with only the new organization fields silently removes supported usage guidance; extend the existing paragraph instead.
    Confidence: 0.99
  • [P3] Remove the duplicate category property — src/agents/tools/sessions-tool.ts:518-520
    category is added twice to the same patch object. The later spread currently wins, but this is the duplicate-property condition already reported by CodeQL and should be deleted.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5775cd3dfaf4.

Labels

Label changes:

  • add merge-risk: 🚨 session-state: The new agent-facing bulk action can alter persisted category and unread state across up to 100 visible sessions.

Label justifications:

  • P3: This is a bounded session-organization feature, not a demonstrated production regression.
  • merge-risk: 🚨 session-state: The new agent-facing bulk action can alter persisted category and unread state across up to 100 visible sessions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body reports an isolated Gateway check, but this review did not treat that as independent batch-path proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Available current-main blame attributes the affected session documentation and tool-description lines to the current history boundary commit. (role: recent current-main source contributor; confidence: medium; commits: c7f70f338ac1; files: docs/concepts/session-tool.md, src/agents/tool-description-presets.ts)
  • clawsweeper: The provided related PR history identifies this account as author of the merged single-session category surface that this branch extends. (role: merged related-feature author; confidence: high; commits: a480d0347fa8; files: src/agents/tools/sessions-tool.ts, src/agents/tools/sessions-list-tool.ts, docs/concepts/session-tool.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Restore the full sessions_list documentation while adding the new organization fields.
  • Delete the second category spread in the single-session patch object.
  • Attach a redacted trace showing an allowed visible batch and rejection of a tree-external target.

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 (5 earlier review cycles)
  • reviewed 2026-08-19T03:30:27.501Z sha 86c6d92d8a922823e98dde5c81348cd1db9073e3 :: found issues before merge. :: [P1] Rebase away the category implementation already on main | [P2] Document the new bulk session-management contract
  • reviewed 2026-08-19T07:38:00.312Z sha e83f41e :: found issues before merge. :: [P3] Remove the duplicated category property
  • reviewed 2026-08-22T18:53:58.779Z sha e83f41e :: found issues before merge. :: [P2] Restore the full sessions_list contract
  • reviewed August 23, 2026, 1:11 PM ET / 17:11 UTC sha unknown :: needs changes before merge. :: [P2] Restore the full sessions_list contract | [P3] Remove the repeated category property
  • reviewed 2026-08-24T20:16:52.377Z sha e83f41e :: found issues before merge. :: [P2] Restore the full sessions_list contract | [P3] Remove the duplicate category property

@vyctorbrzezowski
vyctorbrzezowski force-pushed the brzezowski/session-organize-tools branch from 86c6d92 to 66d7a13 Compare August 19, 2026 04:24
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: msteams Channel integration: msteams labels Aug 19, 2026
@vyctorbrzezowski
vyctorbrzezowski force-pushed the brzezowski/session-organize-inherit branch from 5766393 to d9e67a1 Compare August 19, 2026 04:25
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review August 19, 2026 04:29
Comment thread src/agents/tools/sessions-tool.ts Fixed
@openclaw-barnacle openclaw-barnacle Bot removed channel: discord Channel integration: discord channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call app: ios App: ios app: macos App: macos app: web-ui App: web-ui cli CLI command changes scripts Repository scripts commands Command implementations extensions: openai extensions: cloudflare-ai-gateway labels Aug 19, 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 docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants