Skip to content

feat(agents): agent-controlled session status, attention, and TTL in the sessions tool - #111583

Merged
steipete merged 4 commits into
mainfrom
claude/session-status-tool
Jul 20, 2026
Merged

steipete merged 4 commits into
mainfrom
claude/session-status-tool

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agents can already draw their session icon and archive/pin/rename via the sessions tool, but they cannot tell the user "I'm blocked, I need you" through the sidebar, and they cannot set a transient status line. When an agent needs a password, a review, or any input, the session row looks idle. Follow-up to the automatic attention states (#111035) — this adds the agent-declared layer discussed with the maintainer.

Why This Change Was Made

Product premise: the agent controls its environment. The model is not prompted toward these actions; they exist in the tool schema for when the agent is blocked or the user asks.

User Impact

The existing sessions tool patch action gains three model-facing fields (discovery confirmed title/icon/pin/archive already existed; a label-clear schema mismatch was fixed):

  • statusNote (≤120 chars, sanitized like lastRunError): a transient sidebar status line for the session. Renders in the subtitle slot with priority automatic attention > agent status > live narration (feat(ui): live agent activity subtitles on running sidebar sessions #111221) > work subtitle.
  • attention: clear | hand | key | alert | flag | lock | hourglass — curated icons from the session-icon registry; requires an active statusNote; amber accent; participates in child bubbling, the 4-child cap bypass, and collapsed-section dots exactly like automatic attention.
  • ttlMinutes (default 30, max 120): the declaration self-clears server-side. It also clears when the user reads/opens the session (the lastReadAt marker), when the next human message arrives at any entry point (gateway, channel, fast-path, command sessions), or when the agent clears it explicitly. Lifecycle-only writes never erase a status set during the same run.
  • Storage: one additive optional agentStatus object on the session entry (no schema-version change, plugin slot key reserved); expired declarations are suppressed during row projection; session events emit explicit null on clear so clients discard stale state. The sidebar also schedules a local invalidation at the server-issued expiry so an idle UI drops expired status without another event.
  • Rides along: a one-line pre-existing crash guard in chat-thread.ts (item.message was cast without the asRecord guard its sibling uses; a message-less chat event crashed the event listener — found while live-testing this feature).
  • Docs: docs/web/control-ui.md documents the behavior.

Evidence

  • sessions-tool schema/executor tests 12 pass (including the model-schema contract test); gateway batch (sessions-patch, session-utils, agent-session-patch) 213 pass; full UI project 4576 pass; focused sidebar suite green post-rebase over feat(ui): live agent activity subtitles on running sidebar sessions #111221 (agent status threaded through the narration-era subtitle resolver with an explicit priority test).
  • All four typecheck lanes clean via node scripts/run-tsgo.mjs (core, core-test, ui, ui-test).
  • Mock-gateway/e2e proof for the rendering path shipped with feat(ui): automatic session attention states in the sidebar #111035/feat(ui): live agent activity subtitles on running sidebar sessions #111221; the agent-status render reuses those exact primitives (attention union, subtitle slot, icon registry).
  • Known gap, explicitly: no live end-to-end model prompt was exercised against a dev gateway (the scratch-gateway session was cut short); the schema-contract test covers what the model sees, and a live check on a real gateway is a 5-minute follow-up.
  • One local test failure ("avatar symlinks stay inside workspace") is environment-specific (macOS /var realpath class) — being baselined against main; CI arbitrates.

@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 Jul 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 11:57 PM ET / July 20, 2026, 03:57 UTC.

Summary
The PR adds expiring agent-declared status notes and attention icons to the sessions tool, gateway session state, generated protocol bindings, and Control UI sidebar.

PR surface: Source +358, Tests +185, Docs 0, Other +12. Total +555 across 34 files.

Reproducibility: no. the PR describes a concrete live-gateway path, but its own evidence says that run was not completed. A high-confidence reproduction/proof is to have an agent call sessions.patch, observe the sidebar, then verify clear-on-read, clear-on-next-human-message, and TTL expiry.

Review metrics: 1 noteworthy metric.

  • Model-facing session patch contract: 3 fields added; 1 persisted session-state object added. The new statusNote, attention, and ttlMinutes fields extend a gateway/tool contract and write agentStatus into durable session metadata.

Stored data model
Persistent data-model change detected: persistent cache schema: src/agents/tools/sessions-tool.ts, persistent cache schema: src/gateway/sessions-patch.test.ts, persistent cache schema: src/sessions/session-agent-status.ts, serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: packages/gateway-protocol/src/session-icon.ts, serialized state: src/agents/command/session-preparation.ts, and 18 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real gateway proof that a model sets the status and the sidebar clears it after read, human reply, and TTL expiry.
  • Obtain maintainer confirmation that the three new model-facing fields and persisted agentStatus semantics are the intended permanent contract.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Tests and mock-gateway coverage support the implementation, but the PR body confirms no real development-gateway model/session lifecycle was completed; add redacted terminal output, logs, or a recording and redact private endpoints, tokens, IP addresses, and user data. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging adds three model-facing sessions.patch fields and a persisted session-state object, so maintainers need to explicitly accept the permanent gateway/tool contract and its clear-on-read, reply, and expiry semantics.
  • [P1] The PR has only test and mock-harness evidence; without a redacted live gateway run, it has not shown that a model declaration reaches the sidebar and clears correctly at the real user-interaction boundaries.

Maintainer options:

  1. Prove and retain the lifecycle (recommended)
    Add a redacted real gateway run showing an agent declaration, sidebar display, clearing after a user read or reply, and TTL expiry before merge.
  2. Accept the contract deliberately
    A maintainer may accept the current persisted session-status semantics after reviewing the gateway/tool API as a permanent model-facing contract.
  3. Pause for product shaping
    Pause the PR if the sidebar should not expose agent-controlled persistent status through the sessions tool.

Next step before merge

  • [P1] A protected maintainer label, a new model-facing gateway contract, and missing real behavior proof require human product and merge review rather than an automated repair.

Maintainer decision needed

  • Question: Should the sessions tool permanently expose agent-controlled statusNote, attention, and ttlMinutes as a persisted gateway/session contract with the proposed automatic clearing rules?
  • Rationale: This is a new model-facing protocol and persisted session-state capability, so tests can validate mechanics but cannot determine the intended long-term product contract or operator expectations.
  • Likely owner: steipete — Recent merged ownership of the adjacent attention and narration surfaces makes this person the best available routing candidate for the intended contract.
  • Options:
    • Sponsor the current contract (recommended): Keep the existing three-field design and merge after real gateway lifecycle proof confirms declaration and every intended clearing boundary.
    • Narrow the contract: Reduce the exposed fields or persistence semantics before merge if agent-declared sidebar presence should remain a smaller or less durable capability.
    • Defer the feature: Pause this PR if the agent-controlled status layer needs broader sidebar-product direction before adding it to the gateway protocol.

Security
Cleared: The diff adds no dependency, workflow, secret, permission, package-resolution, or external code-execution surface; the relevant concern is session-state correctness rather than a concrete security regression.

Review details

Best possible solution:

Keep one additive agent-status contract in the existing sessions tool and gateway projection, then land it only after a maintainer confirms the product semantics and a real gateway run proves declaration, read/reply clearing, and TTL expiry.

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

No; the PR describes a concrete live-gateway path, but its own evidence says that run was not completed. A high-confidence reproduction/proof is to have an agent call sessions.patch, observe the sidebar, then verify clear-on-read, clear-on-next-human-message, and TTL expiry.

Is this the best way to solve the issue?

Unclear; the patch uses the existing attention and subtitle architecture, which is the narrowest apparent implementation path, but maintainers must first confirm that these three model-facing persisted-state fields are the desired permanent contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 503b21dc6bfd.

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded, user-visible session and sidebar capability rather than an urgent regression or availability incident.
  • merge-risk: 🚨 session-state: The PR adds durable agentStatus state whose expiry and interaction-driven clearing determine what users see across session lifecycle events.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Tests and mock-gateway coverage support the implementation, but the PR body confirms no real development-gateway model/session lifecycle was completed; add redacted terminal output, logs, or a recording and redact private endpoints, tokens, IP addresses, and user data. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +358, Tests +185, Docs 0, Other +12. Total +555 across 34 files.

View PR surface stats
Area Files Added Removed Net
Source 27 382 24 +358
Tests 5 186 1 +185
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 12 0 +12
Total 34 581 26 +555

What I checked:

  • Current-main comparison: Current main's gateway session patch implementation has no statusNote, attention, ttlMinutes, or agent-status projection path; this PR introduces the missing behavior rather than duplicating a current capability. (src/gateway/sessions-patch.ts:419, 503b21dc6bfd)
  • Persisted status lifecycle: The proposed patch stores an optional agentStatus record, validates and projects it only before expiry, clears it at human-turn admission, and emits null in session events after a clear. (src/gateway/sessions-patch.ts:419, 4a5d2d0a7e41)
  • Existing UI owner path: The implementation extends the already-merged automatic-attention and live-narration sidebar work, retaining the existing precedence shape rather than creating a parallel presentation surface. (ui/src/components/session-row-subtitle.ts:18, 3a5da4faa8c5)
  • Feature-history provenance: The linked merged sidebar attention and narration work appears to establish the relevant feature direction; both merge commits predate this PR and are attributable to the same recent area contributor. (ui/src/components/app-sidebar-session-attention.ts:97, 6c2973dee416)
  • Proof gap: The PR body explicitly says the live development-gateway model/session run was not completed; tests and mock-gateway evidence are useful supplemental validation but do not demonstrate the after-fix lifecycle in a real setup. (4a5d2d0a7e41)

Likely related people:

  • steipete: Previously authored the merged automatic session-attention and sidebar-narration work that this PR deliberately extends, and authored the current session-status implementation. (role: recent area contributor; confidence: high; commits: 6c2973dee416, 3a5da4faa8c5, 4a5d2d0a7e41; files: ui/src/components/app-sidebar-session-attention.ts, ui/src/components/session-row-subtitle.ts, src/gateway/sessions-patch.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-20T02:30:49.484Z sha 3b055d5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:13:45.783Z sha 3b055d5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:40:04.883Z sha 9580dd0 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 20, 2026
@steipete
steipete merged commit bc76bb8 into main Jul 20, 2026
128 of 130 checks passed
@steipete
steipete deleted the claude/session-status-tool branch July 20, 2026 04:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 20, 2026
…the sessions tool (openclaw#111583)

* feat(agents): agent-controlled session status, attention, and TTL in the sessions tool

* feat(protocol): sessions.patch agent status fields and curated attention icon ids

* chore(protocol): regenerate bindings for agent-status patch fields, unexport internal cap

* chore(sessions): unexport internal agent-status TTL default
@steipete

Copy link
Copy Markdown
Contributor Author

Live model verification (post-land, dev gateway on current main): GPT-5.6 Luna, prompted only in natural language, performed exactly one openclaw.sessions action: "patch" call setting statusNote "Waiting for the staging password", attention icon lock, TTL 5 minutes, and thread title "Staging deploy" — all four new fields discovered from the schema alone, thread visibly renamed in the UI. Screenshot: https://raw.githubusercontent.com/steipete/openclaw-pr-assets/main/session-attention/live-model-test.png (Note: gateway startup was initially wedged by the pre-existing prepared-model-runtime timeout regression, resolved by #111701 — on current main the gateway boots in 1.2s.)

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: web-ui App: web-ui 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant