Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions app/agent_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,6 @@ def _build_db_interface(self, *, data_dir: str, chroma_path: str):
# Components a selective reset can target. Order matters only for the
# human-readable summary; each block is independent.
RESET_COMPONENTS = (
"conversation",
"sessions",
"memory",
"workspace",
Expand Down Expand Up @@ -2601,9 +2600,10 @@ async def _reset_selected_components(self, components: "Iterable[str]") -> str:
rest. Unknown component names are ignored (logged).
"""
selected = {str(c).strip().lower() for c in components if str(c).strip()}
# Legacy name from the old task system maps onto sessions.
if "tasks" in selected:
# Legacy names map onto the single chats component.
if "tasks" in selected or "conversation" in selected:
selected.discard("tasks")
selected.discard("conversation")
selected.add("sessions")
unknown = selected - set(self.RESET_COMPONENTS)
if unknown:
Expand All @@ -2616,30 +2616,25 @@ async def _reset_selected_components(self, components: "Iterable[str]") -> str:

done: list[str] = []

# Conversation: the MAIN session's conversation (chat + activity
# rows) plus global usage events. Other sessions' history is their
# own — deleting it belongs to the "sessions" component.
if "conversation" in selected:
# Chats: delete extra chat sessions, empty Main, and wipe Living UI
# conversation history only (apps stay unless "livingui" is selected).
if "sessions" in selected:
try:
from app.usage import (
get_chat_storage,
get_action_storage,
get_usage_storage,
)

get_chat_storage().clear_messages(MAIN_SESSION_ID)
get_action_storage().clear_items(MAIN_SESSION_ID)
count = await self._delete_all_chat_sessions()
get_chat_storage().clear_messages()
get_action_storage().clear_items()
get_usage_storage().clear_events()
self.session_manager.clear_session(MAIN_SESSION_ID)
done.append("conversation")
except Exception as e:
logger.warning(f"[RESET] conversation reset failed: {e}")

# Sessions: delete all chat sessions (main + living UI stay).
if "sessions" in selected:
try:
count = await self._delete_all_chat_sessions()
done.append(f"sessions ({count} deleted)")
for session in list(self.session_manager.sessions.values()):
if session.type == SessionType.LIVING_UI:
self.session_manager.clear_session(session.id)
done.append(f"sessions ({count} chats deleted)")
except Exception as e:
logger.warning(f"[RESET] sessions reset failed: {e}")

Expand Down
12 changes: 12 additions & 0 deletions app/ui_layer/adapters/browser_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4287,6 +4287,18 @@ async def _handle_reset(self, data: dict | None = None) -> None:
result = await reset_agent_state(self._controller, components=components)

if result.get("success"):
# Chats (id "sessions", plus the legacy "conversation" alias):
# clear transcripts, the action panel, and push the session list
# so extra chats drop from the sidebar without a refresh.
chats_reset = (
components is None
or "sessions" in components
or "conversation" in components
)
if chats_reset:
await self._chat.clear()
await self._action_panel.clear()
await self._handle_session_list()
# Only clear the UI panels whose data was actually reset.
if components is None:
# Full reset: everything is gone.
Expand Down
10 changes: 3 additions & 7 deletions app/ui_layer/browser/frontend/src/components/ui/ResetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ interface ResetItem {
}

export const RESET_ITEMS: ResetItem[] = [
{
id: 'conversation',
label: 'Main chat history',
description: 'Chat messages and the action log of the Main chat.',
},
{
id: 'sessions',
label: 'Chat sessions',
description: 'All chat sessions and their history.',
label: 'Chats',
description:
'Delete extra chats, clear Main, and clear Living UI chat history. Apps are kept.',
},
{
id: 'memory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ export function GeneralSettings() {
<h4>Reset Agent</h4>
</div>
<p className={styles.dangerDescription}>
Reset the agent to its initial state. This will clear chat sessions, conversation history,
and restore the agent file system from templates. Saved settings and credentials are preserved.
Reset selected parts of the agent. Chats can be wiped without deleting
Living UI apps. Saved settings and credentials are preserved.
</p>
<Button
variant="danger"
Expand Down
6 changes: 3 additions & 3 deletions app/ui_layer/commands/builtin/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def help_text(self) -> str:
return """Reset the agent to its initial state.

This will:
- Delete all chat sessions and clear the main session
- Clear action history
- Reset the conversation context
- Delete extra chat sessions and clear the main session
- Clear Living UI chat history (Living UI apps are kept)
- Clear action history and conversation context

Note: This does not affect saved settings or credentials."""

Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/core/commands/builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Removes tasks whose status is completed, failed, or cancelled from the task pane

## /reset

Resets the agent to its initial state: clears the current task, action history, and conversation context, and wipes the chat view. Saved settings and credentials are **not** affected. Feedback arrives as system messages while the reset runs in the background.
Resets the agent to its initial state: deletes extra chat sessions, clears Main, and clears Living UI chat history (Living UI **apps** are kept unless you choose that option in Settings → Reset Agent). It also restores the agent's markdown files in `agent_file_system/` from their templates, rebuilds the memory index, and clears dashboard usage data. Workspace outputs are wiped too. Saved settings and credentials are **not** affected. Feedback arrives as system messages while the reset runs in the background.

## /exit

Expand Down