Skip to content

feat(sessions): find sessions worth organizing - #126177

Closed
vyctorbrzezowski wants to merge 9 commits into
openclaw:brzezowski/session-organize-toolsfrom
vyctorbrzezowski:brzezowski/session-organize-search
Closed

vyctorbrzezowski wants to merge 9 commits into
openclaw:brzezowski/session-organize-toolsfrom
vyctorbrzezowski:brzezowski/session-organize-search

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Related: #126064, #118910, #118912
Stacked on #126146.

What Problem This Solves

Agents can organize sessions in batch, but existing metadata filtering is incomplete, and transcript search limits messages before diversifying by session. One conversation with many strong hits can therefore hide other matching sessions.

Why This Change Was Made

sessions.list and sessions_list gain cheap metadata filters for category, owner, unread state, run status, project, worktree presence, and attention. The Gateway applies them before sorting, pagination, row projection, title derivation, or transcript preview reads.

sessions_search gains resultMode: "sessions", capped at 100. The existing SQLite FTS5 query groups by durable sessionId before applying the limit and returns one best bounded excerpt per session. It never hydrates complete transcripts or adds an index/table.

This broader canonical implementation explicitly supersedes the narrower category-only search in #118912 without editing or landing that contributor PR.

User Impact

An agent can search for a topic, inspect one result per matching session, and use the stacked batch tool to group up to 100 sessions in two model tool calls.

Evidence

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

  • Blacksmith Testbox tbx_01m0c2b41z73stqkfy6bk0mgbf: 75/75 focused FTS, Gateway, filter-owner, pre-hydration, and agent-adapter tests passed.
  • Blacksmith Testbox tbx_01m0c2pcq5qj50ftnfmrtfh0jk: 188/188 protocol, FTS, Gateway, embedded parity, agent-tool, and Control UI tests passed.
  • Rebased top head tbx_01m0c42zyxk68mtvhb5qtqmpa6: 188/188 passed.
  • FTS proof: 101 matching sessions returned 100 distinct session results with truncated: true; a hot session with four hits no longer hid another session at limit 2.
  • Pre-hydration proof: a category filter reduced a 30-row store to one row before title hydration received scopes.
  • Blacksmith Testbox tbx_01m0c33de0hnra2ybsghd45bah: protocol-since guard, Swift/Kotlin generation checks, and full build passed; Control UI startup stayed within budget.
  • Blacksmith Testbox tbx_01m0c7cpszxst7tzmbjcffv270: 296 focused protocol, Gateway, FTS, and embedded-tool tests passed after the schema/handler ownership split.
  • Blacksmith Testbox tbx_01m0ca4ncjccf1fde7pm7y03ha: full build passed after changed typecheck, lint, guard, and docs gates completed cleanly in run 32220762269.
  • Blacksmith Testbox tbx_01m0cbd652t68thcqa9tw0b0dy: 7/7 focused Control UI E2E tests passed for the explicit resultMode: "messages" request contract.
  • Prompt/tool inventory delta: +1,189 chars, approximately +297 tokens. No single injected item approaches the 1K-token review threshold.
  • No SQLite schema/version change, table, index, config surface, or server-side rules engine.

Provenance

The existing FTS session search landed in #105057 and the Gateway handler split in #107677. Category search is tracked by #118910/#118912. This PR extends those canonical owners instead of adding a second search engine.

Production-vs-test LOC

Production/docs/generated: +498/-214 (net +284). Tests/test fixtures: +283/-45 (net +238). The ownership cleanup moves sessions.search out of sessions-read.ts and leaves that file 143 lines smaller. Persistence remains unchanged.

Exact-head repair evidence

Head 7a0a28e74e3d2bc7aa415e4a7b5184ea7af3d0ae rebases this PR onto the current #126146 head and resolves the review findings:

  • sessions.list now uses one canonical live-run projection for both status filtering and returned row status in Gateway and embedded mode. A persisted failed row with a live run is found by status: \"running\" and returned as running.
  • Category is part of the shared server-side free-text corpus and the Swift/Android cached fallback corpora.
  • Gateway, agent-tool, and embedded boundaries reject malformed, unknown, empty, null, and wrong-type resultMode values; both valid modes remain accepted.
  • Focused TypeScript proof: 9 files, 169 tests passed across protocol, Gateway, active-run owner, agent tool, and embedded parity.
  • pnpm build passed.
  • Changed gates passed formatting, guards, deadcode, core/test typecheck, and core lint. The app lane then hit the unrelated existing test/scripts/package-mac-app.test.ts expectation for missing pnpm/corepack stderr; it reproduces in isolation and does not touch this PR surface.
  • Swift and Android tests could not run on this Linux host because Swift and Java are unavailable; exact-head CI owns those native lanes.
  • Final autoreview: clean, no accepted/actionable findings.
  • Codex contract checked directly at codex-rs/protocol/src/dynamic_tools.rs and codex-rs/app-server/src/dynamic_tools.rs: dynamic tool input schemas remain JSON schema and failed calls remain explicitly typed.

Repair commits production delta: +142/-71 (net +71); tests: +139/-7 (net +132). The production growth is the shared live-run projection contract plus native fallback parity; duplicate Gateway filter/row recomposition was removed.

@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 docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 19, 2026
@vyctorbrzezowski
vyctorbrzezowski force-pushed the brzezowski/session-organize-search branch from beed12f to 6f2636f Compare August 19, 2026 04:24
@openclaw-barnacle openclaw-barnacle Bot added 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 cli CLI command changes scripts Repository scripts commands Command implementations extensions: openai extensions: cloudflare-ai-gateway extensions: xiaomi channel: qa-channel Channel integration: qa-channel extensions: qa-lab extensions: codex extensions: lmstudio channel: synology-chat plugin: zoom Zoom plugin labels Aug 19, 2026
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Remote Control UI proof on final head 52fbf1a8dea5f64a0ee838af0abe0859003f9ea3:

  • Blacksmith Testbox tbx_01m0ccrdq101112q3ref6g8w2w: 6/6 session transcript-search E2E tests passed.
  • The inspected recording shows query entry, one provenance-bearing transcript result, and navigation to the matching chat.
session-transcript-search.mp4

@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 10:29 AM ET / 14:29 UTC.

ClawSweeper review

What this changes

Adds session-organization search filters and a message-oriented result mode across agent tools, Gateway, native clients, UI, docs, and tests.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: the branch adds session-discovery behavior not present on current main, but it advertises an unsupported icon filter and needs repair plus a current-main restack.

Priority: P2
Reviewed head: 7a0a28e74e3d2bc7aa415e4a7b5184ea7af3d0ae
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The feature has broad focused coverage, but the remaining model-schema mismatch and stale-stack integration gap prevent a higher rating.
Proof confidence 🌊 off-meta tidepool Not applicable: The contributor is a repository member; the available Control UI recording is for an older head and was not used as exact-head proof.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor is a repository member; the available Control UI recording is for an older head and was not used as exact-head proof.
Evidence reviewed 5 items Introduced schema-description mismatch: The PR head advertises filtering all listed fields, including icon, but the sessions_list input schema has no icon parameter; icon is output-only. The wording was introduced by PR commit 8643a2a over parent 602ecb6.
Prompt and docs repeat the unsupported capability: The same broad filtering claim appears in the session-tool documentation and Codex dynamic-tool snapshot, while the protocol documentation enumerates supported filters without icon.
Current main lacks the proposed discovery expansion: Current main retains the existing 25-result sessions search contract and does not define resultMode or this PR's enhanced list-filter surface, so the central behavior is not already implemented.
Findings 1 actionable finding [P1] Do not advertise icon filtering
Security None None.

How this fits together

Session tools let agents inspect and organize sessions through Gateway-backed list and search operations. Tool schemas and descriptions guide model calls, while Gateway and native clients apply filters and return bounded session results.

flowchart LR
  A[Agent request] --> B[Session tool schema]
  B --> C[Tool description]
  B --> D[Gateway session search]
  C --> A
  D --> E[Session records]
  D --> F[Native and UI clients]
  E --> G[Bounded search results]
  F --> G
Loading

Decision needed

Question Recommendation
Should this draft be sponsored as a fresh main-targeted restack of its distinct session-discovery filters and result mode after #136952? Sponsor a narrow restack: Repair the unsupported icon claim and restack the distinct discovery behavior onto current main with focused cross-client validation.

Why: The feature remains absent from current main, but its closed unmerged base and subsequent session-tool redesign require an owner to choose whether the capability is worth reintegrating.

Before merge

  • Do not advertise icon filtering (P1) - sessions_list says it can filter all listed fields, including icon, but its input schema exposes no icon parameter. This steers the model to an unsupported call; the same false claim is copied into user docs and the Codex dynamic-tool snapshot.
  • Resolve merge risk (P1) - The branch is based on a closed, unmerged stack and predates current-main session-tool and group-vocabulary changes; merging it without a fresh restack could reintroduce retired contracts or omit current behavior.
  • Complete next step (P2) - Remove the unsupported icon-filter promise, then restack the distinct feature onto current main and provide exact-head Gateway, Android, Apple, and Control UI validation.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Do not advertise icon filtering — src/agents/tool-description-presets.ts:68
Agent review details

Security

None.

PR surface

Source +321, Tests +388, Docs +8, Other +36. Total +753 across 44 files.

View PR surface stats
Area Files Added Removed Net
Source 15 568 247 +321
Tests 22 443 55 +388
Docs 3 11 3 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 4 40 4 +36
Total 44 1062 309 +753

Review metrics

Metric Value Why it matters
Production versus test LOC production/docs +591/-254; tests +443/-55; generated +28/-0 The feature spans Gateway, protocol, tools, native clients, UI, docs, and regression coverage, so it needs a current-main integration pass.

Stored data model

Persistent data-model change detected: unknown-data-model-change: packages/gateway-protocol/src/schema/sessions-list-search.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/sessions.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair and restack before merge (recommended)
    Remove the unsupported icon-filter promise and rebase the distinct feature onto current main before evaluating compatibility with current session tools.
  2. Pause the draft
    Close or retain the draft only as reference if maintainers do not want an additional session-discovery surface.

Technical review

Best possible solution:

Repair the prompt/docs claim, then implement only the distinct discovery capability as a narrow current-main restack using current group vocabulary and actual supported filters.

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

Yes: the model-facing description explicitly claims icon filtering while the PR input schema omits icon; an icon-filter tool call is therefore schema-rejected, although no execution was run in this read-only review.

Is this the best way to solve the issue?

No: correcting the unsupported promise is necessary, and the remaining feature needs a fresh main-aligned design and validation pass rather than merging the stale stack.

Full review comments:

  • [P1] Do not advertise icon filtering — src/agents/tool-description-presets.ts:68
    sessions_list says it can filter all listed fields, including icon, but its input schema exposes no icon parameter. This steers the model to an unsupported call; the same false claim is copied into user docs and the Codex dynamic-tool snapshot.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 79f0df31c8eb.

Labels

Label changes:

  • remove merge-risk: 🚨 session-state: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P2: This is a bounded session-organization improvement with a model-facing capability mismatch, not an outage or data-loss incident.
  • merge-risk: 🚨 compatibility: The closed-stack base predates current-main changes to the session tool contract and terminology, so an unreviewed merge could disrupt existing callers.
  • 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: The contributor is a repository member; the available Control UI recording is for an older head and was not used as exact-head proof.

Evidence

Acceptance criteria:

  • [P1] Validate sessions_list schema and description parity.
  • [P1] Run focused Gateway, Android, Apple, and Control UI session-discovery coverage at the rebased head.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ZYV5ge: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Remove the icon-filter promise from the description, docs, and snapshot.
  • Restack the distinct behavior onto current main and validate the Gateway, Android, Apple, and Control UI paths.

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 (7 earlier review cycles)
  • reviewed 2026-08-19T09:37:51.856Z sha 52fbf1a :: found issues before merge. :: [P1] Preserve category in the established free-text search | [P2] Validate result mode in the embedded Gateway path
  • reviewed 2026-08-22T18:53:56.236Z sha 52fbf1a :: found issues before merge. :: [P1] Restore category in free-text session search | [P2] Validate result mode in the embedded Gateway path
  • reviewed 2026-08-24T07:10:34.538Z sha a32217b70e815d2414e5e09282d57f0fd0ecd799 :: found issues before merge. :: [P1] Preserve live status filtering in embedded mode | [P1] Restore category in free-text session search | [P2] Validate embedded session-search parameters
  • reviewed 2026-08-25T08:41:46.065Z sha f524678 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T08:59:22.468Z sha 7a0a28e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T11:58:15.886Z sha 7a0a28e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T14:17:11.928Z sha 7a0a28e :: blocked before merge. :: [P1] Do not advertise unsupported icon filtering

@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Superseded by @steipete's session tool rework on main: #132942 unified the sidebar vocabulary on group and #136952 added generic batching through action=patch with targets (src/agents/tools/sessions-tool.ts, sessions-tool-patch.ts), including partial-success results keyed by index. This draft kept the category vocabulary and a separate patch_many action with all-or-nothing failure semantics and results keyed by session key, so rebasing would mean choosing between two batch contracts rather than replaying the change. Closing; the organization and search features can come back as an adaptation on top of the group + patch/targets contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant