Liking cljdoc? Tell your friends :D

Design: Automatic Session Purpose Renaming

Status: Proposal Scope: extension design, extension/runtime capability fit, non-code gap analysis

Problem

Session names currently reflect either an explicit manual label or a fallback based on recent user text. As work progresses, the purpose of a session can shift substantially while the visible session name lags behind. This makes session trees, resume flows, and long-running work harder to scan.

We want an extension that keeps a session name aligned with the session's current purpose without adding user-facing noise or mutating the source conversation.

Goals

  • Keep the visible session name aligned with the current purpose of the conversation.
  • Rename automatically in the background as the session evolves.
  • Derive the new name from the conversation itself, not from tool traces or hidden reasoning.
  • Avoid polluting the source session transcript.
  • Avoid visible helper sessions in normal user workflows.
  • Avoid races, recursion, and excessive rename churn.

Non-goals

  • Perfect semantic summarization.
  • Preserving a rename history in v1.
  • Reviewing each proposed rename with the user.
  • Retroactive repair of old session names.
  • Persisting scheduled rename work across process restart.

Proposed user-visible behavior

For each eligible session, after every N completed prompt-lifecycle turns, when the session has returned to :idle, the extension evaluates whether the session name should change.

Default:

  • N = 2

The evaluation runs in the background. If it succeeds and the result is still current, the original session name is updated to a terse phrase describing the current purpose of the session.

If it fails, the original session remains unchanged.

Definitions

Eligible session

A session is eligible when all of the following hold:

  • it is a normal user session, not an internal helper session
  • automatic renaming is enabled for that session/project/runtime
  • it is not currently protected by a manual-name policy

Completed turn

A completed turn is one source-session assistant turn that has fully completed on the shared prompt lifecycle and returned the session to :idle.

Implications:

  • streamed partial output does not count
  • individual tool calls do not count
  • tool-use continuation remains part of the same turn until terminal completion

Current purpose

The current purpose is the best terse description of what the session is now trying to achieve, based on user-visible conversation content.

Proposed rename workflow

When the source session reaches the rename threshold:

  1. Capture a source-session revision marker.
  2. Build a sanitized conversation view from the source session.
  3. Start one internal helper run for rename inference.
  4. Ask for the current purpose as a terse phrase.
  5. Validate the proposed title.
  6. Re-check that the source session has not moved on.
  7. Apply the new name to the original session.

Revision marker

The rename workflow must capture enough source-session state to detect staleness before applying the result.

The marker should identify the source snapshot used for inference, for example:

  • completed-turn count
  • latest journal entry identity
  • latest session update timestamp

Exact representation is an implementation detail, but the workflow must be able to answer: "Has the source session advanced since the rename evaluation began?"

If yes, discard the result.

Sanitized conversation view

The rename inference must use a sanitized view of the source session.

Include

  • user textual messages
  • assistant visible textual replies
  • compacted/summary assistant text if it is part of the visible conversation

Exclude

  • tool calls
  • tool results
  • hidden/provider reasoning or thinking
  • slash commands and navigation commands
  • background-job terminal chatter
  • extension/system noise that does not express user intent or assistant-visible task progress

Helper execution model

The rename inference should run in an internal helper context rather than in the source session itself.

Required properties:

  • not user-facing in normal session navigation
  • does not alter the source transcript
  • does not recursively trigger the auto-rename extension
  • tools disabled
  • thinking disabled
  • single-response execution

Preferred shape:

  • create an internal child/helper session or equivalent isolated execution context
  • seed it with the sanitized conversation view
  • append a final user prompt asking for the current purpose

Prompt contract

Recommended prompt:

Based on this conversation, what is the current purpose of the session? Reply with only a terse phrase of 2–8 words. No quotes. No explanation.

The result should be treated as invalid if it does not satisfy the response contract.

Validation rules

A proposed title is valid when it satisfies all of the following:

  • non-blank
  • single-line
  • within configured maximum length
  • within configured word-count range
  • not just punctuation or quoting
  • not an explanation sentence when a phrase was requested

Suggested defaults:

  • 2–8 words
  • max 60 characters

Apply rules

Apply the proposed rename only when:

  • the helper run completed successfully
  • the result validates
  • the normalized new name differs from the current normalized name
  • the source session revision marker still matches
  • manual-name protection policy does not block the write

Concurrency rules

For each source session:

  • allow at most one rename inference job in flight
  • if another trigger arrives while one is running, either coalesce into one pending rerun or skip until the next threshold
  • never let an older result overwrite a newer session state

Manual rename policy

This must be explicit. Recommended v1 policy:

  • track whether the current name is user-authored or auto-derived
  • if the current name is manual, auto-rename is suppressed until re-enabled

Alternative policies are possible, but the system should not silently oscillate between user intent and automatic renaming.

Failure policy

On helper-run failure, validation failure, or stale-source detection:

  • leave the original session name unchanged
  • do not inject failure text into the source transcript
  • optional diagnostic UI/status may be added later, but v1 should default to silent failure

Cost and cadence

This feature adds one extra model inference every N completed turns per eligible session.

To bound cost and churn, v1 should support:

  • enable/disable switch
  • configurable rename cadence N
  • optional helper-model override
  • no-tools helper execution
  • thinking disabled

Recommended configuration surface

Suggested extension configuration:

  • :enabled? — default true
  • :turn-interval — default 2
  • :max-title-chars — default 60
  • :min-words — default 2
  • :max-words — default 8
  • :helper-model — optional override
  • :manual-name-policy — default :suppress-when-manual
  • :debug-visibility? — default false

Architectural preference

Prefer an event-driven workflow over timer polling.

Preferred trigger model:

  • observe prompt-lifecycle turn completion
  • count completed turns
  • schedule or enqueue a background rename job only when a threshold is crossed

A scheduler may still be useful for debounce/coalescing, but a blind periodic polling loop is not the preferred architecture.

Open design questions

  1. Should helper runs use the session's current model or a dedicated cheap model?
  2. Should compaction summaries be included when they are the best current visible representation of the conversation?
  3. Should manual names suppress auto-renaming forever, or only until an explicit reset?
  4. Should helper contexts be persisted at all, or be purely ephemeral runtime state?
  5. Should this extension expose user-visible status when rename inference is in progress?

Acceptance criteria

  • A source session can be automatically renamed without mutating its transcript.
  • Rename evaluation happens only after completed turns and idle transition.
  • The inference input excludes tool calls, tool results, and hidden thinking.
  • Helper runs do not recursively trigger rename inference.
  • Stale helper results are discarded.
  • Manual-name policy is enforced.
  • The user-visible session tree shows updated names for successfully applied renames.

Gap Analysis

This section evaluates whether the current architecture appears to provide the necessary pieces for the design.

Summary

The system appears to have most of the major building blocks needed for this extension, but not yet all of them as a clean extension-facing path.

Current fit:

  • strong for session renaming
  • strong for isolated helper execution primitives
  • moderate for background workflow/job execution
  • moderate for scheduling primitives
  • weak to moderate for canonical trigger and transcript-sanitization surfaces
  • weak for explicit metadata/policy around manual vs automatic names

Capability fit by concern

1. Renaming the source session

Present

The platform already exposes the ability to set a session name.

Fit

Strong. This part appears ready.

Gap

The current visible model appears to support a name string, but the design also benefits from name metadata such as:

  • name source (manual vs auto)
  • updated-at
  • derivation marker

Without this metadata, conflict handling between user renames and automatic renames will be brittle.

2. Running rename inference outside the source session

Present

The platform appears to support child/helper session creation and execution in an isolated context.

Fit

Strong, conceptually.

Gap

The design needs a clean distinction between:

  • user-facing sessions
  • internal helper sessions used only for extension logic

If helper sessions are visible in normal session navigation, the feature will introduce noise and confusion.

3. Background execution

Present

The runtime already has workflow-backed background jobs and job reconciliation.

Fit

Moderate to strong.

Gap

The extension needs a simple canonical way to express:

  • one rename job per source session
  • in-flight suppression/coalescing
  • silent helper execution
  • stale-result discard before apply

These are architectural policies on top of the current job substrate and should be made explicit.

4. Scheduling/debounce

Present

A scheduler primitive exists in the runtime/dispatch layer.

Fit

Moderate.

Gap

It is not yet clear that extensions have a clean, direct, high-level scheduling surface for "run this rename evaluation after the next eligible idle boundary" or "debounce repeated triggers".

This may not block the feature if workflow/background execution can be triggered from lifecycle events, but it does mean that "use the scheduler" is currently a design preference rather than a clearly complete extension surface.

5. Triggering every N completed turns

Present

The prompt lifecycle is explicit and completed-turn semantics exist in the architecture.

Fit

Moderate.

Gap

The design needs a canonical extension-observable hook for:

  • completed prompt-lifecycle turn
  • session returned to idle
  • source session identity

If extensions do not currently receive a clean event at that semantic boundary, then the runtime is missing the most natural trigger surface for this feature.

This is the single most important likely gap.

6. Building a sanitized transcript

Present

The system already distinguishes user-visible display content from some command noise, and transcript/message projections exist.

Fit

Moderate.

Gap

The extension needs a canonical sanitized conversation view tailored to purpose inference, not merely a raw journal dump.

Needed semantics include exclusion of:

  • tool calls/results
  • hidden reasoning/thinking
  • slash commands
  • background-job chatter
  • extension/system noise

If each extension has to reconstruct this on its own, behavior will be inconsistent and fragile. A shared projection or query surface would make this feature much cleaner.

7. Preventing recursion

Present

Helper contexts and extension workflows exist, so recursion can likely be avoided by convention.

Fit

Moderate.

Gap

The design needs an explicit way to mark helper contexts as internal and make extension triggers ignore them. Without a standard marker, recursion prevention will be ad hoc.

8. Stale-result protection

Present

The architecture already values explicit routing and traceable lifecycle stages.

Fit

Moderate.

Gap

The extension needs a stable source revision marker or equivalent read-model so it can determine whether the source session advanced during the helper run.

Without a canonical notion of "source snapshot version", stale overwrites are more likely.

9. Manual vs automatic naming policy

Present

Session names exist.

Fit

Weak.

Gap

There does not appear to be a first-class naming policy model. The proposed feature needs one, even if minimal.

At minimum, the architecture should answer:

  • was this name set manually or automatically?
  • should auto-rename be allowed to overwrite it?

10. User-facing observability

Present

The UI and background-job systems can surface status if desired.

Fit

Moderate.

Gap

This is optional for v1, but operationally useful. If the extension silently fails all renames, users may not know whether the feature is disabled, blocked, or merely finding no better title.

A lightweight optional observability surface may be desirable later.

Recommended runtime-facing additions

These are not code-level prescriptions; they are capability-level additions that would make the extension clean and robust.

  1. Completed-turn extension event

    • A canonical event emitted when a session turn fully completes and the session returns to idle.
  2. Sanitized conversation projection

    • A shared read-model for "purpose inference conversation".
  3. Internal helper-session marker

    • A standard way to create or mark extension-owned helper contexts as non-user-facing and non-recursive.
  4. Name metadata / policy model

    • Support for distinguishing manual and automatic names.
  5. High-level extension scheduling/debounce surface

    • A cleaner extension-facing capability for coalesced delayed work.
  6. Source revision marker

    • A stable session-version concept suitable for stale-result detection.

Recommendation

This extension is viable, but it should be treated as a feature that will also clarify a few missing extension/runtime seams.

Recommended path:

  1. establish the trigger surface at completed-turn/idle boundary
  2. establish a canonical sanitized conversation projection
  3. establish helper-session/internal-run semantics
  4. define manual-vs-auto naming policy
  5. build the extension on top of those clarified surfaces

With those pieces in place, the extension should be straightforward and architecturally consistent.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close