Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Backend-native session title backfill
Background
agent_sessions.title is currently a Vibe-owned display field. Workbench-created
sessions may have a title, but IM-created sessions usually leave it empty. Native
backend sessions also have their own naming behavior:
- OpenCode currently receives
title="vibe-remote:{base_session_id}"when a new native session is created. This blocks OpenCode's own title generation, because OpenCode only auto-generates a semantic title while its title still matches the defaultNew session - <ISO timestamp>format. - Codex does not receive a title from Vibe Remote. Its local thread store has
title,first_user_message, andpreviewfields. - Claude Code does not receive a title from Vibe Remote through the current
SDK path. The CLI has session naming / rename concepts, but the SDK options
used here do not expose a first-class title/name field, and the stable local
session index exposes
firstPrompt, not a reliable generatedtitle. Product direction: use the first user message's first 10 visible characters as the Claude fallback title.
The current OpenCode behavior is backwards for product quality: Vibe Remote injects a technical title, then loses access to the backend's better title.
Goal
Use backend-native titles as the source of truth for empty Vibe session titles:
- Do not pass a Vibe-generated title/name to any backend when creating a native session.
- Pull the backend's native title after a turn has enough context to name the conversation.
- Backfill
agent_sessions.titleonly while it is still empty and not user-owned. - Never overwrite a title the user has edited.
Non-goals
- Do not add a Vibe-side LLM title generator in this change.
- Do not try to force Claude Code to accept a title via undocumented CLI flags or by mutating Claude's private storage.
- Do not rewrite historical session titles in a migration. This is a forward behavior change; optional historical backfill can be a separate maintenance command later.
Backend Findings
OpenCode
Confirmed behavior:
POST /sessionwith no title creates a default title likeNew session - 2026-06-02T07:35:03.127Z.- OpenCode stores this in its sqlite
session.titlefield and returns it in the create-session response. - OpenCode source has an
ensureTitlepath that only runs whenSession.isDefaultTitle(session.title)is true. After the first real user message, it asks the built-intitleagent to generate a semantic title and callsSession.setTitle.
Implication:
- Vibe Remote must stop passing
vibe-remote:{base_session_id}. - The initial default title must be ignored for backfill.
- The semantic title should be read after the first turn completes, or on a short delayed retry if it is not available immediately.
Codex
Current behavior:
- Vibe Remote starts Codex threads with
thread/startparams containing cwd, sandbox, approval policy, and developer instructions, but no title. - Codex local state has
threads.title,threads.first_user_message, andthreads.preview. - The existing
CodexNativeSessionProvideralready readstitlefrom the native sqlite store for/resume.
Implication:
- Codex is already aligned with "do not pass title".
- Add a small title pull path that reads the current native thread by id and
returns
threads.titlewhen it is non-empty and not a placeholder.
Claude Code
Current behavior:
- The CLI supports
--nameand rename/display-name concepts. - The current
ClaudeAgentOptionsused by Vibe Remote does not expose a first-classnameortitlefield. - Stable local discovery data currently exposes
sessions-index.jsonfields such asfirstPrompt,sessionId, timestamps, path, and message count. It does not expose a reliable generatedtitle. history.jsonlhasdisplay, but that is a history-entry display string, not a stable session title contract.
Implication:
- Claude should not claim a backend-generated title.
- Claude should expose a low-confidence derived title from the first user message: the first 10 visible characters after trimming whitespace.
- Source should be
derived_first_prompt, notbackend. - Normalize before slicing: trim, collapse whitespace/newlines to a single space, then take the first 10 visible characters. If the first user message has no text content, return no title.
Data Ownership
Use agent_sessions.metadata_json to track title ownership. Avoid adding columns
unless this becomes a heavily queried feature.
Suggested metadata shape:
{
"title_source": "backend",
"title_backend": "opencode",
"title_native_session_id": "ses_...",
"title_synced_at": "2026-06-02T07:40:00Z"
}
When the user edits a session title through the UI/API:
{
"title_source": "user",
"title_user_modified_at": "2026-06-02T07:40:00Z"
}
Rules:
title_source=usermeans backend title sync must never overwrite it.- Empty
titlewith missing/other source is eligible for backend backfill. - Backend backfill sets
title_source=backend. - Once a non-empty title is written into Vibe, backend sync should not overwrite it. This keeps the rule simple: backfill empty titles only.
- Placeholder backend titles must not be written.
Proposed Abstraction
Add a small backend title provider contract instead of duplicating storage logic inside each agent implementation.
@dataclass(slots=True)
class BackendSessionTitle:
title: str
source: Literal["backend", "derived_first_prompt"]
confidence: Literal["high", "low"]
class BackendSessionTitleProvider(Protocol):
def get_title(
self,
*,
native_session_id: str,
working_path: str,
first_user_message: str = "",
) -> BackendSessionTitle | None:
...
Provider behavior:
OpenCodeSessionTitleProvider: readsession.titleby native id, ignore defaultNew session - ...andChild session - .... When no usable backend title exists, derive from the first user message like Claude.CodexSessionTitleProvider: readthreads.titleby native thread id, ignore empty/default-looking values. Usefirst_user_messageonly if we explicitly choose derived fallback.ClaudeSessionTitleProvider: derive a fallback from the first user message's first 10 visible characters withsource="derived_first_prompt"andconfidence="low".
The derived_first_prompt construction is shared:
modules.agents.native_sessions.base.derive_first_prompt_title() is the single
home for the truncated-first-message title, used by all three providers, so an
agent backend that never sets a title (observed with GLM on OpenCode, which
under-complies with the proactive title prompt) still gets a deterministic
backfilled title.
Implemented shape:
modules/agents/native_sessions/*already contains backend-specific read logic for/resume, so each provider now exposes a focusedget_title().core.session_titles.backfill_agent_session_title()owns the shared orchestration: read first user text, ask the provider, call the storage writer, and publishsession.activityafter a successful write.BaseAgentonly schedules best-effort title sync after successful terminal turns.
Backfill Flow
Trigger title sync after the native session id is known and a turn reaches a terminal state.
Recommended flow:
- Agent creates or resumes native session.
- Vibe Remote binds
native_session_idto the reservedagent_sessionsrow. - User turn completes.
- Agent calls a shared helper:
maybe_backfill_agent_session_title(
agent_session_id=...,
backend=...,
native_session_id=...,
working_path=...,
)
- Helper checks the Vibe session row:
- no row: skip
- non-empty title with
title_source=user: skip - any non-empty title: skip
- empty title: backfill if provider returns an eligible title
- Persist title + metadata.
- Publish a session update event so Workbench sidebar/header refreshes.
OpenCode timing:
- The semantic title may be generated shortly after the first prompt path runs.
- First call after turn completion should try once.
- If the provider returns no title because it is still the default placeholder, schedule one short retry after 3 seconds, without blocking the agent response.
- Do not create a long-running poll loop just for title sync.
UI / API Behavior
Session update API:
- When
PATCH /api/sessions/<id>changestitle, mark metadatatitle_source=user. - Clearing a title should be treated as user intent. Suggested behavior:
- if user sets empty title explicitly, set
title_source=userand keep title empty, so backend sync does not immediately refill it. - if we want "reset to backend title" later, add an explicit reset action.
- if user sets empty title explicitly, set
Workbench display:
- Prefer
agent_sessions.titlewhen present. - If empty, keep current fallback behavior.
- Do not display backend placeholder titles such as
New session - ....
Creation-path confirmation:
- Plain Avibe Workbench chat creation currently calls
api.createSessionwith onlyproject_id; it does not send the localized UI fallbackUntitled session/未命名会话. - Sidebar "new session" also sends only
project_id. - Chat header and sidebar render
Untitled session/未命名会话only as a UI fallback whensession.titleis null/empty. - The backend
create_sessionpath storestitle=Nonewhen the incoming title is missing, empty, or whitespace-only. CreateViaChatDialogis a different, explicit task/watch setup flow and intentionally sends a business title such as Task / Watch; it is not the plain new-chat fallback.
Tests
Unit coverage:
- OpenCode create-session no longer sends
title. - OpenCode provider ignores default
New session - .... - OpenCode provider returns semantic
session.title. - Codex provider returns
threads.title. - Claude provider derives the first 10 visible characters from the first user
message and marks the source as
derived_first_prompt. - Backfill writes title only when Vibe title is empty.
- Backfill does not overwrite
title_source=user. - Backfill does not overwrite an existing backend-owned title.
- User
PATCH titlemarks metadata as user-owned. - Plain Workbench create-session requests without a title persist
agent_sessions.title = NULL; localized fallback strings never enter the DB.
Integration-ish tests:
- Workbench session first turn with OpenCode binds native id and eventually
fills
agent_sessions.titlefrom OpenCode. - Workbench session first turn with Codex fills from Codex native title when available.
- Claude session fills from the first user message's first 10 visible characters.
Regression scenarios:
- Existing IM thread with no Workbench title still replies normally.
- Existing Workbench session renamed by user is not overwritten by a later backend-generated title.
- OpenCode
/resumelist still shows OpenCode native titles through the native session provider.
Implementation Status
Implemented in feature/backend-session-title-backfill:
- Added backend title candidate API and provider implementations.
- Stopped passing
titleto OpenCodecreate_session. - Added shared session-title backfill helper in
core.session_titles. - Called the helper after successful terminal turns for OpenCode, Codex, and Claude.
- Added Claude provider with the first-10-visible-characters fallback.
- Updated session title PATCH path to mark user ownership, including explicit user clears.
- Published session update events after successful backend backfill.
- Added focused tests.
Open Questions
- Should Codex fallback to
first_user_messagewhenthreads.titleis empty, or should only backend-nativetitlecount? - Is
metadata_jsonenough for title ownership, or shouldtitle_sourcebecome a column once filtering/sorting by title origin matters? - Should OpenCode title sync use one short delayed retry, or wait for a later natural session refresh when the semantic title is not ready immediately?