Skip to content

feat(gateway): utility-model auto-titles for sessions beyond dashboard - #107739

Closed
clawsweeper[bot] wants to merge 1 commit into
mainfrom
molty/utility-model-session-titles
Closed

clawsweeper[bot] wants to merge 1 commit into
mainfrom
molty/utility-model-session-titles

Conversation

@clawsweeper

@clawsweeper clawsweeper Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Sessions whose derived title would otherwise fall back to a truncated first message or a session-id prefix now get a one-time LLM-generated title — not just dashboard: sessions. Titles are generated fire-and-forget on the utility model after the session's first user turn and persisted to displayName, where sessions_list and the UI already pick them up.

  • How it triggers: once per session generation, on the first user turn — from the existing gateway chat.send trigger and a new trigger in the reply pipeline covering inbound channel sessions (Discord DMs, groups without a subject, unlabeled subagents, …).
  • How to disable: set utilityModel: "" (per agent or in agents.defaults). No new config knobs — this reuses the existing utility-model routing; unset means the provider's declared small-model default. If routing resolves to nothing, generation is skipped entirely — it never falls back to the primary model, and the deterministic derived title remains.
  • Never overwrites: explicit label, displayName, subject, or origin.label — checked both before generation and again inside the guarded session-store write. ACP sessions, cron runs, slash commands, and system events (heartbeat/cron/exec) are excluded.

Implements the maintainers-Discord discussion started by Omar Shahine about naming sessions with a small (haiku-class) model.

File-by-file details

src/gateway/session-auto-title.ts (renamed from dashboard-session-title.ts)

  • Drops the dashboard:-key restriction; isSessionAutoTitleCandidate now accepts any agent session key, excluding ACP keys, cron-run keys, empty messages, and slash commands.
  • New explicit gate on resolveUtilityModelRefForAgent: utilityModel: "" (or a provider with no declared small-model default) disables generation instead of letting the shared simple-completion path silently fall back to the primary model.
  • Sticky per-session-generation attempt marker (storePath + sessionKey + sessionId): both triggers can fire for one session, but at most one utility request is ever spent — including after a failed model call. Bounded set (4096) for long-lived gateways; eviction is safe because past-first-turn sessions fail the systemSent check anyway.
  • Persistence unchanged: updateSessionEntry with a recheck callback that aborts if the session generation was reset or a name appeared while the model call was in flight.

src/gateway/server-methods/chat.ts

  • Renamed imports/call site (maybeGenerateDashboardSessionTitle → maybeGenerateSessionAutoTitle, plus isSessionAutoTitleCandidate); trigger logic and the emitSessionsChanged broadcast ("chat.title") unchanged.

src/auto-reply/reply/get-reply.ts

  • New fire-and-forget trigger after session prep: first user turn only (!systemSent), skips system-event providers (heartbeat, cron-event, exec-event), uses the finalized message body as the title source. UI refresh for this path rides the existing run-lifecycle sessions.changed events.

src/gateway/session-auto-title.test.ts (renamed)

  • All prior dashboard tests kept (renamed function); new coverage: non-dashboard agent keys generate; non-agent (global)/ACP/cron-run keys, channel subjects, and disabled utility routing skip; failed attempts are not retried within a session generation.

Verification

  • pnpm tsgo:prod ✅ and pnpm tsgo:test:root ✅ (typecheck)
  • oxlint + oxfmt --check on all changed files ✅; pnpm check:import-cycles ✅ (0 cycles)
  • Targeted vitest: title/label-generator modules 66 tests ✅; chat*/get-reply* suites 735 tests across 50 files ✅

🤖 Generated with Claude Code

Generalize the dashboard-only LLM session titling so any agent session
whose derived title would fall back to a truncated first message or a
session-id prefix gets a one-time utility-model title after its first
user turn.

- Rename dashboard-session-title.ts to session-auto-title.ts and drop
  the dashboard-key restriction; add eligibility checks (agent session
  keys only, no ACP/cron-run keys, no slash commands, no explicit
  label/displayName/subject/origin label, first turn only, same session
  generation).
- Gate generation on resolveUtilityModelRefForAgent so an explicit
  utilityModel "" (or a provider without a small-model default)
  disables auto-titles instead of falling back to the primary model.
- Add a sticky per-session-generation attempt marker so the gateway
  chat.send trigger and the reply pipeline trigger spend at most one
  utility request per session, including after failed attempts.
- Trigger fire-and-forget generation from the reply pipeline for
  inbound channel sessions, skipping system events (heartbeat,
  cron-event, exec-event).

Implements the maintainers-Discord proposal to name sessions with a
small model; no new config knobs, reuses existing utilityModel routing.

Co-Authored-By: Claude Fable 5 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M labels Jul 14, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 15, 2026
@clawsweeper

clawsweeper Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex review: found issues before merge. Reviewed August 2, 2026, 6:40 AM ET / 10:40 UTC.

ClawSweeper review

What this changes

The PR expands one-time utility-model session titles from dashboard chats to eligible non-dashboard and inbound-channel sessions.

Merge readiness

⛔ Blocked by patch quality or review findings - 12 items remain

This draft is still useful only if maintainers want automatic titles for inbound-channel and non-dashboard agent sessions, but it is not safe to merge as written. Its unchanged branch bypasses the current title-path ownership boundary, can fall back to the primary model, can overwrite channel or space names, and does not publish reply-pipeline writes to session observers.

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

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 7 items Current title path owns protected names and model routing: Current main preserves groupChannel and space alongside labels and subjects, resolves the session model and auth profile, and passes explicit model selections into the title generator.
Primary fallback remains reachable from the PR: The PR only checks for a utility-model reference before calling generateConversationLabel; that generator retries with the primary model after utility preparation or completion fails, contradicting the stated no-primary-fallback behavior.
Current tests define channel and space names as protected: Current main explicitly skips title generation for sessions with groupChannel or space; the PR replacement guard omits both fields.
Findings 3 actionable findings [P1] Bind title generation to the resolved utility model
[P1] Preserve channel and space names before writing displayName
[P2] Publish reply-path session title writes
Security Needs attention Prevent fallback title egress to the primary model: The branch gates on a utility ref but calls a generator whose failure path retries with the primary model, potentially sending first-message content through a different provider or auth profile than the operator selected for utility tasks.

How this fits together

Gateway chat and inbound reply handling prepare session records before running an agent turn. The title helper derives a bounded display name from the first user message, resolves model and auth ownership, persists it to the session record, and notifies session-list clients.

flowchart LR
  A[Gateway chat or inbound reply] --> B[Session preparation]
  B --> C[Title eligibility]
  C --> D[Utility model and auth resolution]
  D --> E[Guarded session record update]
  E --> F[Session change event]
  F --> G[Session lists and clients]
Loading

Decision needed

Question Recommendation
Should OpenClaw automatically spend utility-model requests to replace deterministic titles for inbound-channel and non-dashboard agent sessions, or should generated titles remain dashboard-scoped? Keep dashboard scope: Do not merge this draft and retain generated titles only for dashboard session rows.

Why: Extending this behavior changes default model use and user-visible naming beyond the existing dashboard scope, while current main centralizes the required session-specific model, auth, and protected-name contracts.

Before merge

  • Bind title generation to the resolved utility model (P1) - resolveUtilityModelRefForAgent is only a gate here; generateConversationLabel independently retries the primary model after utility preparation or completion does not yield a label. Pass the resolved ref and auth owner through a fail-closed title-generation API instead.
  • Preserve channel and space names before writing displayName (P1) - The replacement guard omits groupChannel and space, both of which current main treats as explicit session names. A channel session with either field can therefore have its operator-visible name overwritten.
  • Publish reply-path session title writes (P2) - The reply-pipeline trigger starts a detached update but does not emit sessions.changed after it persists. Connected session lists can retain the deterministic title until an unrelated lifecycle event; publish the matching update after a successful write.
  • Resolve security concern: Prevent fallback title egress to the primary model - The branch gates on a utility ref but calls a generator whose failure path retries with the primary model, potentially sending first-message content through a different provider or auth profile than the operator selected for utility tasks.
  • Resolve merge risk (P1) - The draft can send first-message content through a session's primary model after the utility attempt fails, despite its stated routing and opt-out guarantee.
  • Resolve merge risk (P1) - The draft can replace existing groupChannel or space names with generated text.
  • Resolve merge risk (P1) - The detached reply-pipeline write does not notify connected session clients, leaving them with a stale deterministic title until another lifecycle event.
  • Resolve merge risk (P1) - No contributor-provided after-fix real-behavior proof is available in the supplied body or scratch artifacts; listed tests and checks are supplemental only.
  • Complete next step (P2) - A maintainer must first choose whether automatic cross-channel session titling is an intended default; the current draft then needs a substantive rebase rather than a bounded mechanical repair.
  • Improve patch quality - Resolve the security review concern or explain why the changed path is safe.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P1] Bind title generation to the resolved utility model — src/gateway/session-auto-title.ts:106-124
  • [P1] Preserve channel and space names before writing displayName — src/gateway/session-auto-title.ts:45-51
  • [P2] Publish reply-path session title writes — src/auto-reply/reply/get-reply.ts:567-577
  • [medium] Prevent fallback title egress to the primary model — src/gateway/session-auto-title.ts:118
Agent review details

Security

Needs attention: No supply-chain change is present, but the title path can route first-message content through the primary model after utility-model failure, contrary to the stated egress and credential boundary.

PR surface

Source +63, Tests +40. Total +103 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 187 124 +63
Tests 1 55 15 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 242 139 +103

Review metrics

Metric Value Why it matters
Automatic title triggers 2 trigger paths The branch adds gateway-chat and reply-pipeline triggers, so model routing, auth ownership, duplicate suppression, and observer updates must hold across both.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/session-auto-title.test.ts, serialized state: src/gateway/session-auto-title.ts, unknown-data-model-change: src/gateway/session-auto-title.test.ts, unknown-data-model-change: src/gateway/session-auto-title.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase onto the current title owner (recommended)
    Move the extension onto current main's title API and preserve its session-specific model, profile, and explicit-name contracts before merge.
  2. Keep titles dashboard-scoped
    Pause or close the draft if maintainers do not want automatic utility-model calls for channel or non-dashboard sessions.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase the title extension onto current main; pass the resolved utility model and auth owner through a fail-closed generation API, preserve groupChannel and space, publish the reply-path session update, add focused tests, and include redacted after-fix runtime proof.

Technical review

Best possible solution:

Keep the current dashboard title helper as the canonical owner, then—if maintainers sponsor cross-channel titles—rebase a narrow extension that passes the resolved utility model and auth owner into a fail-closed generation API, preserves every explicit-name field, and publishes a session update after persistence.

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

Yes for the patch defects: utility-model failure reaches the primary fallback in generateConversationLabel, and a session with groupChannel or space reaches the PR's incomplete overwrite guard. A live run was not possible in this read-only, network-unavailable environment.

Is this the best way to solve the issue?

No. The branch predates the current title-path owner and duplicates its routing and persistence policy instead of extending it; a rebased, fail-closed API is the safer route if maintainers sponsor the feature.

Full review comments:

  • [P1] Bind title generation to the resolved utility model — src/gateway/session-auto-title.ts:106-124
    resolveUtilityModelRefForAgent is only a gate here; generateConversationLabel independently retries the primary model after utility preparation or completion does not yield a label. Pass the resolved ref and auth owner through a fail-closed title-generation API instead.
    Confidence: 0.99
  • [P1] Preserve channel and space names before writing displayName — src/gateway/session-auto-title.ts:45-51
    The replacement guard omits groupChannel and space, both of which current main treats as explicit session names. A channel session with either field can therefore have its operator-visible name overwritten.
    Confidence: 0.99
  • [P2] Publish reply-path session title writes — src/auto-reply/reply/get-reply.ts:567-577
    The reply-pipeline trigger starts a detached update but does not emit sessions.changed after it persists. Connected session lists can retain the deterministic title until an unrelated lifecycle event; publish the matching update after a successful write.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is an optional ergonomics feature, not a current behavior regression, but default cross-channel model calls require deliberate review.
  • merge-risk: 🚨 compatibility: The draft replaces the current dashboard-only helper with an older policy that omits protected-name fields and conflicts with newer main behavior.
  • merge-risk: 🚨 auth-provider: A failed utility attempt can retry on the session's primary model and its credentials instead of ending title generation.
  • merge-risk: 🚨 security-boundary: The primary fallback can send first-message content to a provider or auth boundary outside the utility-model route selected for this task.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

Security concerns:

  • [medium] Prevent fallback title egress to the primary model — src/gateway/session-auto-title.ts:118
    The branch gates on a utility ref but calls a generator whose failure path retries with the primary model, potentially sending first-message content through a different provider or auth profile than the operator selected for utility tasks.
    Confidence: 0.99

What I checked:

  • Current title path owns protected names and model routing: Current main preserves groupChannel and space alongside labels and subjects, resolves the session model and auth profile, and passes explicit model selections into the title generator. (src/gateway/dashboard-session-title.ts:35, 98c0d9deca5d)
  • Primary fallback remains reachable from the PR: The PR only checks for a utility-model reference before calling generateConversationLabel; that generator retries with the primary model after utility preparation or completion fails, contradicting the stated no-primary-fallback behavior. (src/gateway/session-auto-title.ts:106, e029f90cbccd)
  • Current tests define channel and space names as protected: Current main explicitly skips title generation for sessions with groupChannel or space; the PR replacement guard omits both fields. (src/gateway/dashboard-session-title.test.ts:195, 98c0d9deca5d)
  • The normal gateway path emits an observer update after persistence: Current main emits sessions.changed only after the title write reports success. The PR's detached reply-pipeline call has no corresponding publication step. (src/gateway/server-methods/chat-send-background.ts:63, 98c0d9deca5d)
  • Current main materially rewrote the central implementation after this draft: Current dashboard-session-title.ts and conversation-label-generator.ts were introduced in the latest available title-path commit after the PR head, while supplied PR metadata reports the branch dirty against current main. (src/gateway/dashboard-session-title.ts:1, 98c0d9deca5d)
  • Feature provenance: Generated dashboard session titles originated in the utility-model feature commit, making that path the appropriate ownership baseline for any expansion. (src/gateway/dashboard-session-title.ts:1, 27d6c8816721)

Likely related people:

  • xingzhou: Introduced the utility-model and generated-session-title feature that current title behavior extends. (role: feature introducer; confidence: medium; commits: 27d6c8816721; files: src/gateway/dashboard-session-title.ts)
  • steipete: Recorded as co-author of the current title helper and label-generator implementation that this draft would need to extend. (role: co-author of current title-path repair; confidence: medium; commits: 98c0d9deca5d; files: src/gateway/dashboard-session-title.ts, src/auto-reply/reply/conversation-label-generator.ts)
  • Shakker: The prior available current-main commit touched the same title and label-generator path during an import-cycle repair. (role: recent adjacent contributor; confidence: low; commits: 8137f9712226; files: src/gateway/dashboard-session-title.ts, src/auto-reply/reply/conversation-label-generator.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 (4 earlier review cycles)
  • reviewed 2026-07-15T09:38:31.977Z sha e029f90 :: found issues before merge. :: [P2] Emit the session update after the title write
  • reviewed 2026-07-16T02:49:33.123Z sha e029f90 :: found issues before merge. :: [P1] Route the completion through the resolved utility model | [P2] Emit the session update after the title write
  • reviewed 2026-07-30T10:36:45.859Z sha e029f90 :: found issues before merge. :: [P1] Pass the resolved utility model into title generation | [P2] Emit a session update after reply-pipeline title writes
  • reviewed 2026-08-01T22:12:37.197Z sha e029f90 :: found issues before merge. :: [P1] Bind title generation to the resolved utility model | [P1] Preserve channel and space names before writing displayName | [P2] Publish a session update after reply-path title writes

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 16, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P2 Normal backlog priority with limited blast radius. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 30, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 27, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 4, 2026
@RomneyDa
RomneyDa deleted the molty/utility-model-session-titles branch October 22, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity 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.

0 participants