Skip to content

The agent that grows with you

refactor: delete the onboarding and start_chat RPCs and the tool-row retry store

alt-glitchbf9bea298a46
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 37b055f69d7..28eec914283 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -2180,28 +2180,6 @@ export interface ProfilesGetAssetResult {
size?: number | null
data?: string | null
}
-/** ``created`` is false when an existing setup profile was found (and returned untouched). */
-export interface OnboardingEnsureSetupProfileResult {
- name: string
- path: string
- created: boolean
-}
-export interface OnboardingEnsureSetupSessionParams {
- messages?: Record<string, unknown>[] | null
-}
-export interface OnboardingEnsureSetupSessionResult {
- profile: string
- session_id: string
- empty: boolean
-}
-export interface OnboardingStateResult {
- eligible: boolean
- intro: OnboardingIntro
- failed_starts: number
- completed_at?: string | null
- profile?: string | null
-}
-export type OnboardingIntro = 'unseen' | 'seen'
/** ``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``). ``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it; ``run_id``: that run's id, which ``onboarding.ended`` names. */
export interface OnboardingRunStateResult {
run: boolean
@@ -2236,11 +2214,6 @@ export interface OnboardingSkipParams {
export interface OnboardingSkipResult {
skipped: boolean
}
-export interface OnboardingResetSetupProfileResult {
- name: string
- path: string
- reset?: boolean
-}
export interface VaultListResult {
items?: VaultItem[]
}
@@ -3675,30 +3648,6 @@ export interface LlmOneshotParams {
export interface LlmOneshotResult {
text: string
}
-/** ``tool_call_id`` names the rejected call; its saved tool row records a started retry (display-only). */
-export interface SessionStartChatParams {
- session_id: string
- profile?: string | null
- tool_call_id: string
- args: StartChatArgs
-}
-/** The ``start_chat`` tool's arguments (``tools/start_chat_tool.py``). */
-export interface StartChatArgs {
- message: string
- title?: string | null
- profile?: string | null
-}
-/** ``tui_gateway/start_chat.py``: ``started`` carries the new chat, ``rejected`` a reason and whether the same arguments may succeed on another try (``retryable``). A call already retried returns that retry's result. */
-export interface SessionStartChatResult {
- status: StartChatStatus
- session_id?: string | null
- profile?: string | null
- title?: string | null
- message?: string | null
- reason?: string | null
- retryable?: boolean | null
-}
-export type StartChatStatus = 'started' | 'rejected'
export interface SystemBatteryParams {
profile?: string | null
}
@@ -5408,13 +5357,6 @@ export interface RpcMethods {
'model.options': { params: ModelOptionsParams; result: ModelOptionsResult }
/** Save an API key for a provider and return its refreshed inventory row. */
'model.save_key': { params: ModelSaveKeyParams; result: ModelSaveKeyResult }
- /** Create-or-read the backend-owned setup profile; the backend picks the name. */
- 'onboarding.ensure_setup_profile': { params: Params; result: OnboardingEnsureSetupProfileResult }
- 'onboarding.ensure_setup_session': { params: OnboardingEnsureSetupSessionParams; result: OnboardingEnsureSetupSessionResult }
- 'onboarding.mark_seen': { params: Params; result: OnboardingStateResult }
- 'onboarding.record_failed_start': { params: Params; result: OnboardingStateResult }
- /** Restore the setup profile to its created state in place (soul, memories, skills, sessions). */
- 'onboarding.reset_setup_profile': { params: Params; result: OnboardingResetSetupProfileResult }
/** Write onboarding.run in the root profile's config.yaml; answers the new state. */
'onboarding.set_run': { params: OnboardingSetRunParams; result: OnboardingRunStateResult }
/** Skip setup: end the session's onboarding run and close the card that waits. */
@@ -5589,8 +5531,6 @@ export interface RpcMethods {
'session.save': { params: SessionSaveParams; result: SessionSaveResult }
/** Set/clear hidden (out of the default list, still resumable by its owner) on a session + lineage. */
'session.set_hidden': { params: SessionSetHiddenParams; result: SessionSetHiddenResult }
- /** Run a start_chat request again from the session that made it (the handoff card's Retry). */
- 'session.start_chat': { params: SessionStartChatParams; result: SessionStartChatResult }
/** Rendered /status text for the session. */
'session.status': { params: SessionStatusParams; result: SessionStatusResult }
/** Inject text into the next tool result without interrupting the turn. */
@@ -5822,11 +5762,6 @@ export const RPC_METHODS = [
'model.disconnect',
'model.options',
'model.save_key',
- 'onboarding.ensure_setup_profile',
- 'onboarding.ensure_setup_session',
- 'onboarding.mark_seen',
- 'onboarding.record_failed_start',
- 'onboarding.reset_setup_profile',
'onboarding.set_run',
'onboarding.skip',
'onboarding.start',
@@ -5914,7 +5849,6 @@ export const RPC_METHODS = [
'session.resume',
'session.save',
'session.set_hidden',
- 'session.start_chat',
'session.status',
'session.steer',
'session.title',
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index a52eaf1dfc1..801cc6072bd 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -2022,96 +2022,6 @@
}
}
},
- {
- "name": "onboarding.ensure_setup_profile",
- "summary": "Create-or-read the backend-owned setup profile; the backend picks the name.",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/Params"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/OnboardingEnsureSetupProfileResult"
- }
- }
- },
- {
- "name": "onboarding.ensure_setup_session",
- "summary": "",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/OnboardingEnsureSetupSessionParams"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/OnboardingEnsureSetupSessionResult"
- }
- }
- },
- {
- "name": "onboarding.mark_seen",
- "summary": "",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/Params"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/OnboardingStateResult"
- }
- }
- },
- {
- "name": "onboarding.record_failed_start",
- "summary": "",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/Params"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/OnboardingStateResult"
- }
- }
- },
- {
- "name": "onboarding.reset_setup_profile",
- "summary": "Restore the setup profile to its created state in place (soul, memories, skills, sessions).",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/Params"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/OnboardingResetSetupProfileResult"
- }
- }
- },
{
"name": "onboarding.set_run",
"summary": "Write onboarding.run in the root profile's config.yaml; answers the new state.",
@@ -3678,24 +3588,6 @@
}
}
},
- {
- "name": "session.start_chat",
- "summary": "Run a start_chat request again from the session that made it (the handoff card's Retry).",
- "params": [
- {
- "name": "params",
- "schema": {
- "$ref": "#/components/schemas/SessionStartChatParams"
- }
- }
- ],
- "result": {
- "name": "result",
- "schema": {
- "$ref": "#/components/schemas/SessionStartChatResult"
- }
- }
- },
{
"name": "session.status",
"summary": "Rendered /status text for the session.",
@@ -20421,78 +20313,6 @@
"title": "OnboardingEndedPayload",
"type": "object"
},
- "OnboardingEnsureSetupProfileResult": {
- "additionalProperties": false,
- "description": "``created`` is false when an existing setup profile was found (and returned untouched).",
- "properties": {
- "name": {
- "title": "Name",
- "type": "string"
- },
- "path": {
- "title": "Path",
- "type": "string"
- },
- "created": {
- "title": "Created",
- "type": "boolean"
- }
- },
- "required": [
- "name",
- "path",
- "created"
- ],
- "title": "OnboardingEnsureSetupProfileResult",
- "type": "object"
- },
- "OnboardingEnsureSetupSessionParams": {
- "additionalProperties": false,
- "properties": {
- "messages": {
- "anyOf": [
- {
- "items": {
- "additionalProperties": true,
- "type": "object"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Messages"
- }
- },
- "title": "OnboardingEnsureSetupSessionParams",
- "type": "object"
- },
- "OnboardingEnsureSetupSessionResult": {
- "additionalProperties": false,
- "properties": {
- "profile": {
- "title": "Profile",
- "type": "string"
- },
- "session_id": {
- "title": "Session Id",
- "type": "string"
- },
- "empty": {
- "title": "Empty",
- "type": "boolean"
- }
- },
- "required": [
- "profile",
- "session_id",
- "empty"
- ],
- "title": "OnboardingEnsureSetupSessionResult",
- "type": "object"
- },
"OnboardingFactsSource": {
"enum": [
"local",
@@ -20501,14 +20321,6 @@
"title": "OnboardingFactsSource",
"type": "string"
},
- "OnboardingIntro": {
- "enum": [
- "unseen",
- "seen"
- ],
- "title": "OnboardingIntro",
- "type": "string"
- },
"OnboardingOutcome": {
"enum": [
"done",
@@ -20519,30 +20331,6 @@
"title": "OnboardingOutcome",
"type": "string"
},
- "OnboardingResetSetupProfileResult": {
- "additionalProperties": false,
- "properties": {
- "name": {
- "title": "Name",
- "type": "string"
- },
- "path": {
- "title": "Path",
- "type": "string"
- },
- "reset": {
- "default": true,
- "title": "Reset",
- "type": "boolean"
- }
- },
- "required": [
- "name",
- "path"
- ],
- "title": "OnboardingResetSetupProfileResult",
- "type": "object"
- },
"OnboardingRunStateResult": {
"additionalProperties": false,
"description": "``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh\ninstall). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).\n``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it;\n``run_id``: that run's id, which ``onboarding.ended`` names.",
@@ -20711,53 +20499,6 @@
"title": "OnboardingStartResult",
"type": "object"
},
- "OnboardingStateResult": {
- "additionalProperties": false,
- "properties": {
- "eligible": {
- "title": "Eligible",
- "type": "boolean"
- },
- "intro": {
- "$ref": "#/components/schemas/OnboardingIntro"
- },
- "failed_starts": {
- "title": "Failed Starts",
- "type": "integer"
- },
- "completed_at": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Completed At"
- },
- "profile": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Profile"
- }
- },
- "required": [
- "eligible",
- "intro",
- "failed_starts"
- ],
- "title": "OnboardingStateResult",
- "type": "object"
- },
"OpenRequestEntry": {
"additionalProperties": false,
"description": "One unanswered server\u2192client request (``server_requests.Request.snapshot``); the reconnecting\nclient re-delivers it to its request handlers.",
@@ -32885,128 +32626,6 @@
"title": "SessionSetHiddenResult",
"type": "object"
},
- "SessionStartChatParams": {
- "additionalProperties": false,
- "description": "``tool_call_id`` names the rejected call; its saved tool row records a started retry (display-only).",
- "properties": {
- "session_id": {
- "title": "Session Id",
- "type": "string"
- },
- "profile": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Profile"
- },
- "tool_call_id": {
- "title": "Tool Call Id",
- "type": "string"
- },
- "args": {
- "$ref": "#/components/schemas/StartChatArgs"
- }
- },
- "required": [
- "session_id",
- "tool_call_id",
- "args"
- ],
- "title": "SessionStartChatParams",
- "type": "object"
- },
- "SessionStartChatResult": {
- "additionalProperties": false,
- "description": "``tui_gateway/start_chat.py``: ``started`` carries the new chat, ``rejected`` a reason and whether the same\narguments may succeed on another try (``retryable``). A call already retried returns that retry's result.",
- "properties": {
- "status": {
- "$ref": "#/components/schemas/StartChatStatus"
- },
- "session_id": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Session Id"
- },
- "profile": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Profile"
- },
- "title": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Title"
- },
- "message": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Message"
- },
- "reason": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Reason"
- },
- "retryable": {
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Retryable"
- }
- },
- "required": [
- "status"
- ],
- "title": "SessionStartChatResult",
- "type": "object"
- },
"SessionStatusParams": {
"additionalProperties": false,
"properties": {
@@ -36100,53 +35719,6 @@
"title": "SpawnTreeSaveResult",
"type": "object"
},
- "StartChatArgs": {
- "additionalProperties": false,
- "description": "The ``start_chat`` tool's arguments (``tools/start_chat_tool.py``).",
- "properties": {
- "message": {
- "title": "Message",
- "type": "string"
- },
- "title": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Title"
- },
- "profile": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "title": "Profile"
- }
- },
- "required": [
- "message"
- ],
- "title": "StartChatArgs",
- "type": "object"
- },
- "StartChatStatus": {
- "enum": [
- "started",
- "rejected"
- ],
- "title": "StartChatStatus",
- "type": "string"
- },
"StatusUpdatePayload": {
"additionalProperties": false,
"description": "``server._status_update`` and the direct emitters (goal / loop / heartbeat / process).",
diff --git a/hermes_state.py b/hermes_state.py
index e50b059a13f..4b67b8f46b4 100644
--- a/hermes_state.py
+++ b/hermes_state.py
@@ -73,7 +73,6 @@ from hermes_state_wal import (
)
from hermes_state_repair import _claim_repair_attempt, preflight_db_writability, repair_state_db_schema
from hermes_state_titles import SessionTitlesMixin
-from hermes_state_tool_retries import SessionToolRetriesMixin
from hermes_state_usage import SessionUsageMixin
from hermes_state_maintenance import SessionMaintenanceMixin
from hermes_state_gateway import SessionGatewayMixin
@@ -462,7 +461,7 @@ class SessionDB(
SessionSessionsMixin, SessionFtsSetupMixin, SessionSearchMixin, SessionSchemaMixin,
SessionPortabilityMixin, SessionTelegramTopicsMixin, SessionCompressionMixin,
SessionGatewayMixin, SessionMaintenanceMixin, SessionUsageMixin, SessionTitlesMixin,
- SessionMessagesMixin, SessionCoverageMixin, SessionRewindMixin, SessionProfileRepairMixin, SessionToolRetriesMixin,
+ SessionMessagesMixin, SessionCoverageMixin, SessionRewindMixin, SessionProfileRepairMixin,
):
"""SQLite-backed session storage with FTS5 search; many reader threads, one writer (WAL)."""
diff --git a/hermes_state_tool_retries.py b/hermes_state_tool_retries.py
deleted file mode 100644
index 7928b92face..00000000000
--- a/hermes_state_tool_retries.py
+++ /dev/null
@@ -1,81 +0,0 @@
-"""Tool-retry mixin for SessionDB: a card's Retry (the start_chat handoff card) records its outcome on the
-original tool row's ``display_metadata``. The row the model replays stays byte-identical, so the cached prefix
-survives; a reload shows the outcome, and ``announced`` tells the model once, on the next user turn (the
-reactions pattern)."""
-
-from __future__ import annotations
-
-from typing import Any, Dict, List, Optional, Tuple
-
-from hermes_state_common import _placeholders, _sql_json_extract
-from hermes_state_messages import _DISPLAY_ACTIVE_CLAUSE, _SET_DISPLAY_META_SQL
-
-
-class SessionToolRetriesMixin:
- """Retry outcomes stamped on tool rows, and their one-time announcement to the model."""
-
- TOOL_RETRY_METADATA_KEY = "retried"
-
- def tool_row_retry(self, session_id: str, tool_call_id: str) -> Optional[tuple[int, Optional[dict[str, Any]]]]:
- """``(row id, recorded retry outcome or None)`` of the newest visible tool row for *tool_call_id* in the
- session's resume lineage, or ``None`` when no such row is saved."""
- if not session_id or not tool_call_id:
- return None
- lineage = self._resume_lineage_ids(session_id)
- row = self._read_one(
- "SELECT id, display_metadata FROM messages WHERE role = 'tool' AND tool_call_id = ? "
- f"AND session_id IN ({_placeholders(lineage)}){_DISPLAY_ACTIVE_CLAUSE} ORDER BY id DESC LIMIT 1",
- (tool_call_id, *lineage))
- if row is None:
- return None
- retried = (self._decode_display_metadata(row["display_metadata"]) or {}).get(self.TOOL_RETRY_METADATA_KEY)
- result = retried.get("result") if isinstance(retried, dict) else None
- return row["id"], result if isinstance(result, dict) else None
-
- def set_tool_row_retry(self, row_id: int, outcome: dict[str, Any]) -> None:
- """Record *outcome* as the retry of tool row *row_id*, not yet announced to the model."""
- def _do(conn):
- row = conn.execute("SELECT display_metadata FROM messages WHERE id = ?", (row_id,)).fetchone()
- if row is None:
- return
- meta = self._decode_display_metadata(row[0]) or {}
- meta[self.TOOL_RETRY_METADATA_KEY] = {"result": outcome, "announced": False}
- conn.execute(_SET_DISPLAY_META_SQL, (self._encode_display_metadata(meta), row_id))
- self._execute_write(_do)
-
- def take_unannounced_tool_retries(self, session_id: str) -> list[dict[str, Any]]:
- """``{result, tool_name}`` for each retry the model has not heard about yet, marked announced."""
- if not session_id:
- return []
- lineage = self._resume_lineage_ids(session_id)
- key = self.TOOL_RETRY_METADATA_KEY
- # Every turn of every desktop chat asks. The LIKE pre-filter skips the JSON parse on rows that cannot hold
- # the key (nearly all of them); json_extract still decides.
- select = ("SELECT id, tool_name, display_metadata FROM messages "
- f"WHERE session_id IN ({_placeholders(lineage)}){_DISPLAY_ACTIVE_CLAUSE} "
- f"AND display_metadata LIKE '%\"{key}\"%' "
- f"AND {_sql_json_extract('display_metadata', '$.' + key)} IS NOT NULL ORDER BY id")
-
- def _unannounced(row) -> Optional[dict[str, Any]]:
- meta = self._decode_display_metadata(row["display_metadata"]) or {}
- retried = meta.get(key)
- if not isinstance(retried, dict) or retried.get("announced") or not isinstance(retried.get("result"), dict):
- return None
- return meta
-
- # Every turn asks; almost none have a retry to announce. Read first so those turns never take the write lock.
- if not any(_unannounced(row) for row in self._read_all(select, tuple(lineage))):
- return []
-
- def _do(conn):
- pending = []
- for row in conn.execute(select, tuple(lineage)).fetchall():
- meta = _unannounced(row)
- if meta is None:
- continue
- retried = meta[key]
- retried["announced"] = True
- conn.execute(_SET_DISPLAY_META_SQL, (self._encode_display_metadata(meta), row["id"]))
- pending.append({"result": retried["result"], "tool_name": row["tool_name"] or "tool"})
- return pending
- return self._execute_write(_do)
diff --git a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
index c9841005003..e4ec66b0b8c 100644
--- a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
+++ b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py
@@ -355,49 +355,6 @@ method("profiles.get_asset", params=ProfilesGetAssetParams, result=ProfilesGetAs
# ── onboarding (methods_onboarding) ───────────────────────────────────────────────────────────
-class OnboardingEnsureSetupProfileResult(Result):
- """``created`` is false when an existing setup profile was found (and returned untouched)."""
-
- name: str
- path: str
- created: bool
-
-
-method("onboarding.ensure_setup_profile", params=Params, result=OnboardingEnsureSetupProfileResult,
- doc="Create-or-read the backend-owned setup profile; the backend picks the name.")
-
-
-class OnboardingEnsureSetupSessionParams(Params):
- messages: list[dict[str, JsonValue]] | None = None
-
-
-class OnboardingEnsureSetupSessionResult(Result):
- profile: str
- session_id: str
- empty: bool
-
-
-method("onboarding.ensure_setup_session", params=OnboardingEnsureSetupSessionParams,
- result=OnboardingEnsureSetupSessionResult)
-
-
-class OnboardingIntro(WireEnum):
- unseen = "unseen"
- seen = "seen"
-
-
-class OnboardingStateResult(Result):
- eligible: bool
- intro: OnboardingIntro
- failed_starts: int
- completed_at: str | None = None
- profile: str | None = None
-
-
-method("onboarding.record_failed_start", params=Params, result=OnboardingStateResult)
-method("onboarding.mark_seen", params=Params, result=OnboardingStateResult)
-
-
class OnboardingRunStateResult(Result):
"""``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh
install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).
@@ -471,16 +428,6 @@ method("onboarding.skip", params=OnboardingSkipParams, result=OnboardingSkipResu
doc="Skip setup: end the session's onboarding run and close the card that waits.")
-class OnboardingResetSetupProfileResult(Result):
- name: str
- path: str
- reset: bool = True
-
-
-method("onboarding.reset_setup_profile", params=Params, result=OnboardingResetSetupProfileResult,
- doc="Restore the setup profile to its created state in place (soul, memories, skills, sessions).")
-
-
# ── vault (methods_vault) ─────────────────────────────────────────────────────────────────────
diff --git a/tui_gateway/contracts/sessions.py b/tui_gateway/contracts/sessions.py
index 9de8a849c7e..10f19a975d4 100644
--- a/tui_gateway/contracts/sessions.py
+++ b/tui_gateway/contracts/sessions.py
@@ -1,7 +1,6 @@
"""Session lifecycle contracts (``tui_gateway/methods_session.py``): create / resume / activate /
close, the live-session snapshot those share, history + compression + undo, mid-turn corrections,
listing/browsing stored rows, spawn-tree snapshots, event replay and the stateless one-shot LLM call.
-``session.start_chat`` lives in ``tui_gateway/methods_start_chat.py``.
"""
from __future__ import annotations
@@ -779,42 +778,3 @@ class LlmOneshotResult(Result):
method("llm.oneshot", params=LlmOneshotParams, result=LlmOneshotResult,
doc="Stateless one-shot LLM completion (titles, ideas) on the session's or the task backend.")
-
-# ── start_chat ────────────────────────────────────────────────────────────────────────────────
-
-
-class StartChatArgs(Params):
- """The ``start_chat`` tool's arguments (``tools/start_chat_tool.py``)."""
-
- message: str
- title: str | None = None
- profile: str | None = None
-
-
-class SessionStartChatParams(SessionParams):
- """``tool_call_id`` names the rejected call; its saved tool row records a started retry (display-only)."""
-
- tool_call_id: str
- args: StartChatArgs
-
-
-class StartChatStatus(WireEnum):
- started = "started"
- rejected = "rejected"
-
-
-class SessionStartChatResult(Result):
- """``tui_gateway/start_chat.py``: ``started`` carries the new chat, ``rejected`` a reason and whether the same
- arguments may succeed on another try (``retryable``). A call already retried returns that retry's result."""
-
- status: StartChatStatus
- session_id: str | None = None
- profile: str | None = None
- title: str | None = None
- message: str | None = None
- reason: str | None = None
- retryable: bool | None = None
-
-
-method("session.start_chat", params=SessionStartChatParams, result=SessionStartChatResult,
- doc="Run a start_chat request again from the session that made it (the handoff card's Retry).")
diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.py
index c036cc44a79..a966e3f322c 100644
--- a/tui_gateway/methods_onboarding.py
+++ b/tui_gateway/methods_onboarding.py
@@ -5,49 +5,6 @@ from .method_ctx import HandlerRegistry, bind_module
_registry = HandlerRegistry()
method = _registry.method
-# These handlers run on the RPC pool. Two overlapping kickoffs must not both find no setup
-# profile and create a second one, or both find an empty setup chat and seed it twice.
-_setup_profile_lock = threading.Lock()
-
-
-@method("onboarding.ensure_setup_profile")
-def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import ensure_setup_profile
- try:
- with _setup_profile_lock:
- setup = ensure_setup_profile()
- if setup.created:
- _mirror_launch_credentials(setup.path, {"share_auth": True})
- except Exception as e:
- return _err(rid, 5073, str(e))
- return _ok(rid, {"name": setup.name, "path": str(setup.path), "created": setup.created})
-
-
-@method("onboarding.ensure_setup_session")
-def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import SETUP_CHAT_TITLE, ensure_setup_profile
- from hermes_state_registry import acquire, release_or_close
- try:
- with _setup_profile_lock:
- setup = ensure_setup_profile()
- if setup.created:
- _mirror_launch_credentials(setup.path, {"share_auth": True})
- db = acquire(setup.path / "state.db")
- try:
- row = db.get_session_by_title(SETUP_CHAT_TITLE)
- if row is None:
- row = {"id": db.create_session(new_session_id(), "desktop"), "message_count": 0}
- db.set_session_title(row["id"], SETUP_CHAT_TITLE)
- if not row["message_count"]:
- row["message_count"] = db.append_messages_batch(row["id"], _coerce_seed_history(params.get("messages")))
- finally:
- release_or_close(db)
- except Exception as e:
- logger.exception("onboarding.ensure_setup_session failed")
- return _err(rid, 5075, str(e))
- return _ok(rid, {"profile": setup.name, "session_id": row["id"], "empty": not row["message_count"]})
-
-
# onboarding.state and onboarding.set_run are unscoped on purpose: onboarding.run and the first-chat
# flag live in the root profile's config.yaml whichever profile this backend was launched under.
@method("onboarding.state")
@@ -280,60 +237,6 @@ def _stage_onboarding_turn_note(sid: str, agent, history_empty: bool) -> None:
agent._gateway_turn_context_notes = f"{prior}\n\n{note}" if prior else note
-@method("onboarding.record_failed_start")
-def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import record_failed_start
- return _onboarding_state_result(rid, record_failed_start)
-
-
-@method("onboarding.mark_seen")
-def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import mark_intro_seen
- return _onboarding_state_result(rid, mark_intro_seen)
-
-
-@method("onboarding.reset_setup_profile")
-def _(rid, params: dict) -> dict:
- from hermes_cli.setup_profile import find_setup_profile, reset_setup_profile
- with _setup_profile_lock:
- found = find_setup_profile()
- if found is None:
- return _err(rid, 4072, "no setup profile to reset")
- _clear_setup_sessions(found[1])
- try:
- setup = reset_setup_profile(_launch_home())
- except Exception as e:
- return _err(rid, 5074, str(e))
- return _ok(rid, {"name": setup.name, "path": str(setup.path), "reset": True})
-
-
-def _onboarding_state_result(rid, change) -> dict:
- from hermes_cli.setup_profile import find_setup_profile, onboarding_eligible
- try:
- state = change()
- found = find_setup_profile()
- except Exception as e:
- logger.exception("onboarding state update failed")
- return _err(rid, 5076, str(e))
- return _ok(rid, {"eligible": onboarding_eligible(), "profile": found[0] if found else None, **state})
-
-
-def _clear_setup_sessions(profile_dir) -> None:
- target = Path(profile_dir).resolve()
- with _sessions_lock:
- live = [sid for sid, sess in _sessions.items()
- if Path(sess.get("profile_home") or _hermes_home).resolve() == target]
- for sid in live:
- _close_session_by_id(sid, end_reason="setup_reset")
- from hermes_state_registry import acquire, release_or_close
- db = acquire(target / "state.db")
- try:
- ids = [row[0] for row in db._read_all("SELECT id FROM sessions")]
- db.delete_sessions(ids, sessions_dir=target / "sessions")
- finally:
- release_or_close(db)
-
-
def register(server) -> None:
from agent.onboarding_record import on_ended
diff --git a/tui_gateway/methods_start_chat.py b/tui_gateway/methods_start_chat.py
deleted file mode 100644
index 89062df4bb2..00000000000
--- a/tui_gateway/methods_start_chat.py
+++ /dev/null
@@ -1,64 +0,0 @@
-"""``session.start_chat``: the handoff card's Retry of a rejected start_chat call, and the next-turn note that tells
-the model about it.
-
-Bodies are rebound onto server.py's globals at install time (see
-method_ctx.bind_module), so they reference server.py globals bare.
-"""
-
-import json
-import threading
-
-from .method_ctx import HandlerRegistry, bind_module
-
-_registry = HandlerRegistry()
-method = _registry.method
-_profile_scoped = _registry.profile_scoped
-
-# Two clicks (two windows) must not both find the call unretried and start two chats.
-_start_chat_retry_lock = threading.Lock()
-
-
-@method("session.start_chat")
-@_profile_scoped
-def _(rid, params: dict) -> dict:
- from tui_gateway.start_chat import _rejected, start_chat
- session, err = _sess_nowait(params, rid)
- if err:
- return err
- tool_call_id = str(params.get("tool_call_id") or "")
- if not tool_call_id:
- return _err(rid, 4002, "tool_call_id is required")
- # A running turn owns its own retries (the setup skill retries a profile rejection itself).
- if session.get("running"):
- return _ok(rid, json.loads(_rejected("This chat is still working; retry when its turn ends.", retryable=True)))
- with _start_chat_retry_lock, _session_db(session) as db:
- found = None if db is None else db.tool_row_retry(str(session.get("session_key") or ""), tool_call_id)
- if found is None:
- return _err(rid, 4004, "no saved start_chat result for that tool_call_id")
- row_id, retried = found
- if retried is not None:
- return _ok(rid, retried)
- outcome = json.loads(start_chat(params.get("args") or {}, params["session_id"]))
- if outcome["status"] == "started":
- db.set_tool_row_retry(row_id, outcome)
- return _ok(rid, outcome)
-
-
-def _pending_tool_retry_notes(session: dict) -> str:
- """Note block for card retries since the last turn (model input only, announced once), or ""."""
- session_key = str(session.get("session_key") or "")
- if not session_key:
- return ""
- try:
- with _session_db(session) as db:
- pending = [] if db is None else db.take_unannounced_tool_retries(session_key)
- except Exception:
- logger.debug("Failed to read pending tool retries", exc_info=True)
- return ""
- return "\n".join(
- f"[The user pressed Retry on your rejected {entry['tool_name']} call. {entry['result'].get('message') or ''}]"
- for entry in pending)
-
-
-def register(server) -> None:
- bind_module(globals(), server, skip=("_",))
diff --git a/tui_gateway/prompt_turn.py b/tui_gateway/prompt_turn.py
index af72efa51eb..15b72adf2e1 100644
--- a/tui_gateway/prompt_turn.py
+++ b/tui_gateway/prompt_turn.py
@@ -724,13 +724,12 @@ def _prepare_turn_input(sid: str, session: dict, st: _TurnRun, text: Any, images
from agent.notification_presentation import event_presentation_muted
if not event_presentation_muted("message.delta", sid):
st.tts_queue, st.thinking_started = _start_turn_voice()
- # Per-turn API-message notes: barge mid-speech, reactions, card retries, HUD surface (per-turn state
+ # Per-turn API-message notes: barge mid-speech, reactions, HUD surface (per-turn state
# that must not touch the byte-stable system prompt).
from tools.tts_streaming import SPEECH_INTERRUPTED_NOTE, take_speech_interrupted
if take_speech_interrupted():
run_message = _prepend_note(run_message, SPEECH_INTERRUPTED_NOTE)
run_message = _prepend_note(run_message, _pending_reaction_notes(session))
- run_message = _prepend_note(run_message, _pending_tool_retry_notes(session))
agent._voice_turn_pending = bool(session.pop("voice_turn", False)) # auxiliary.voice_chat route
return prompt, _prepend_note(run_message, _hud_surface_note(session)), cols, streamer
diff --git a/tui_gateway/server.py b/tui_gateway/server.py
index 1eecbcb0436..96c305c6e3a 100644
--- a/tui_gateway/server.py
+++ b/tui_gateway/server.py
@@ -175,9 +175,8 @@ _DETAIL_MODES = frozenset({"hidden", "collapsed", "expanded"})
# Desktop-polled and under GIL pressure block the WS read loop (false "needs setup", stalled
# interrupts); voice.*/wake.* = SYNCHRONOUS faster-whisper install (300s); session.workspace.move =
# git subprocess probes on an arbitrary (maybe slow) mount; session.save = a full stored-session read + JSON
-# render (up to sessions.max_export_messages rows, ~0.8s at the default cap); onboarding.* setup profile =
-# create_profile skill copy + state.db writes + the first import of the setup scanner; session.start_chat and
-# onboarding.start = session creation + a prompt.submit.
+# render (up to sessions.max_export_messages rows, ~0.8s at the default cap); onboarding.start = session
+# creation + a prompt.submit.
_LONG_HANDLERS = frozenset({
"session.foreign.list", "session.foreign.preview", "session.foreign.import",
"billing.state", "subscription.state", "subscription.preview", "subscription.change",
@@ -193,8 +192,7 @@ _LONG_HANDLERS = frozenset({
"setup.runtime_check", "setup.status", "free_tier.provision", "voice.toggle", "voice.record", "voice.tts", "wake.start",
"wake.status", "session.active_list", "session.branch", "session.compress", "session.list",
"session.resume", "session.save", "session.workspace.move", "shell.exec", "skills.manage", "slash.exec",
- "onboarding.ensure_setup_profile", "onboarding.ensure_setup_session", "onboarding.reset_setup_profile",
- "session.start_chat", "onboarding.start",
+ "onboarding.start",
"command.dispatch", # /goal draft invokes the auxiliary model; never block the RPC reader
"shared_metrics.set", # consent reconcile waits on the metrics store's write lock
})
@@ -3673,8 +3671,7 @@ from . import (
methods_connectors as _methods_connectors, methods_connectors_account as _methods_connectors_account,
methods_display as _methods_display, methods_display_watch as _methods_display_watch,
methods_onboarding as _methods_onboarding, methods_i18n as _methods_i18n, methods_machine as _methods_machine,
- methods_shared_metrics as _methods_shared_metrics, methods_start_chat as _methods_start_chat,
- methods_plugin_catalog as _methods_plugin_catalog)
+ methods_shared_metrics as _methods_shared_metrics, methods_plugin_catalog as _methods_plugin_catalog)
for _m in (
_session_transports, _session_reaper, _session_lifecycle, _session_workdir, _compute_host_bridge, _model_switch,
@@ -3686,6 +3683,6 @@ for _m in (
_methods_bot_relay, _prompt_turn, _billing_view, _methods_projects, _methods_session_foreign,
_methods_session_control, _methods_subagents, _methods_vault, _methods_free_tier, _methods_connectors,
_methods_connectors_account, _methods_display, _methods_display_watch, _methods_onboarding,
- _methods_i18n, _methods_machine, _methods_shared_metrics, _methods_start_chat, _methods_plugin_catalog):
+ _methods_i18n, _methods_machine, _methods_shared_metrics, _methods_plugin_catalog):
_m.register(sys.modules[__name__])
del _m
diff --git a/tui_gateway/start_chat.py b/tui_gateway/start_chat.py
deleted file mode 100644
index 49f1d00d18d..00000000000
--- a/tui_gateway/start_chat.py
+++ /dev/null
@@ -1,92 +0,0 @@
-import json
-from pathlib import Path
-
-TITLE_LIMIT = 40
-
-
-def _rejected(reason: str, retryable: bool = False) -> str:
- """``retryable``: the same arguments may start the chat on another try (the handoff card's Retry)."""
- return json.dumps({"status": "rejected", "reason": reason, "retryable": retryable})
-
-
-# The setup picks the handoff block names, in its order.
-_PICK_LINES = (("name", "Name"), ("connectors", "Apps I picked"), ("plugins", "Plugins I picked"), ("layout", "Layout"))
-
-
-def _setup_learned(cards: dict) -> str:
- """The "What setup learned" block for a handoff from the setup profile: the user's card picks and the
- interpreted scan lines its ``/initiate-setup`` turn recorded, so the task chat has them whatever the model
- wrote. Empty when nothing was recorded."""
- picks = cards.get("picks") or {}
- lines = [f"- {label}: {', '.join(map(str, value)) if isinstance(value, list) else value}"
- for key, label in _PICK_LINES if (value := picks.get(key))]
- lines += [f"- {line}" for line in cards.get("learned") or ()]
- return "\n".join(["What setup learned about me:", *lines]) if lines else ""
-
-
-def _first_steps(cards: dict) -> tuple[list, list]:
- """The connector and plugin ids the task chat sets up before its first task: the apps and plugins picked in
- setup, plus the plugins of a plugin task picked at the fork."""
- ids = cards.get("pick_ids") or {}
- task = (cards.get("plugin_tasks") or {}).get(cards.get("fork_pick") or "") or {}
- install = [*(ids.get("plugins") or ()), *(task.get("plugins") or ())]
- return list(ids.get("connectors") or ()), list(dict.fromkeys(install))
-
-
-def start_chat(args: dict, caller_id: str | None = None) -> str:
- from agent.onboarding import PROFILE_BUILD_FLAG, mark_seen
- from gateway.session_context import get_session_env
- from hermes_cli.profiles import SETUP_PROFILE_MARKER
- from hermes_cli.setup_profile import mark_completed, read_cards
- from hermes_constants import profile_name_for_home
- from tui_gateway import server
- from tui_gateway.transport import bind_transport, reset_transport
-
- caller = server._sessions.get(get_session_env("HERMES_UI_SESSION_ID", "") if caller_id is None else caller_id)
- if caller is None:
- return _rejected("start_chat works only from a chat in the Hermes desktop app.")
- caller_home = Path(caller.get("profile_home") or server._hermes_home)
- message = str(args.get("message") or "").strip()
- if not message:
- return _rejected("message is empty: pass the new chat's first message.")
- title = str(args.get("title") or "").strip()
- if len(title) > TITLE_LIMIT:
- return _rejected(f"title has {len(title)} characters; the limit is {TITLE_LIMIT}.")
- profile = str(args.get("profile") or "").strip() or profile_name_for_home(caller.get("profile_home"))
- try:
- home = server._profile_home(profile)
- except server.ProfileUnavailableError as exc:
- return _rejected(str(exc))
- target_home = Path(home or server._hermes_home)
- from_setup = (caller_home / SETUP_PROFILE_MARKER).is_file()
- if from_setup:
- from agent.first_task_prompt import first_task_tail
-
- with server._session_profile_runtime_scope({"profile_home": str(caller_home)}, hydrate_secrets=False):
- cards = read_cards(caller.get("session_key") or "")
- learned = _setup_learned(cards)
- message = (f"{message}\n\n{learned}" if learned else message) + first_task_tail(*_first_steps(cards))
- token = bind_transport(caller.get("transport"))
- try:
- with server._session_profile_runtime_scope({"profile_home": str(home) if home else None}):
- created = server._create_session(
- None, {"profile": profile or "", "source": caller.get("source"), "title": title})
- if "error" in created:
- return _rejected(created["error"]["message"], retryable=True)
- result = created["result"]
- if from_setup: # its first turn skips the first-contact note: setup already ran
- server._sessions[result["session_id"]]["setup_handoff"] = True
- mark_seen(target_home / "config.yaml", PROFILE_BUILD_FLAG)
- submitted = server._methods["prompt.submit"](None, {"session_id": result["session_id"], "text": message})
- if "error" in submitted:
- server._methods["session.close"](None, {"session_id": result["session_id"]})
- return _rejected(submitted["error"]["message"], retryable=True)
- finally:
- reset_transport(token)
- if from_setup and target_home.resolve() != caller_home.resolve():
- mark_completed()
- name = result["info"]["profile_name"]
- return json.dumps({
- "status": "started", "session_id": result["stored_session_id"], "profile": name, "title": title or None,
- "message": f"Started '{title or message[:TITLE_LIMIT]}' in {name}. Do not call start_chat again for this task.",
- })