Restart#
Restart the gptme process.
This tool allows restarting gptme from within a conversation, which can be useful for applying configuration changes, reloading tools, or recovering from state issues.
- gptme.tools.restart.RESTART_TARGETS: dict[str, str] = {'cli': 'Restart this conversation in the plain CLI (gptme)', 'tui': 'Restart this conversation in the TUI (gptme-tui)', 'web': 'Close this session and open the conversation in the web UI'}
Targets accepted by
/restart <target>, with completion descriptions.
- exception gptme.tools.restart.RestartError
A requested restart/switch can’t be performed; nothing was changed.
- gptme.tools.restart.build_restart_argv(target: Literal['cli', 'tui'], source: Literal['cli', 'tui'], conversation_name: str, argv: list[str] | None = None) list[str]
Build the argv that reopens
conversation_namein another interface.Model, tools, tool format etc. are persisted in the conversation’s config.toml and the workspace is the cwd the new process inherits, so only non-persisted, interface-neutral flags are carried over.
- gptme.tools.restart.check_interface_available(target: Literal['cli', 'tui']) None
Raise RestartError if
targetcan’t run in this installation.
- gptme.tools.restart.complete_restart(partial: str, prev_args: list[str]) list[tuple[str, str]]
Completer for
/restartarguments.
- gptme.tools.restart.execute_restart(code: str | None, args: list[str] | None, kwargs: dict[str, str] | None) Generator[Message, None, None]
Execute restart by confirming intent.
The actual restart happens in the restart_hook (GENERATION_PRE), after all messages have been saved to the log.
- gptme.tools.restart.get_server_url() str
Base URL of the local gptme-server.
GPTME_SERVER_URLif set, else built from the environment the server itself reads (GPTME_SERVER_HOST/GPTME_SERVER_PORT, default 127.0.0.1:5700).
- gptme.tools.restart.open_web(url: str) None
Release this session (conversation lock) and open
urlin a browser.The caller must exit right after: once the web UI has the conversation, this process must not write to it.
- gptme.tools.restart.parse_restart_target(args: list[str]) Literal['cli', 'tui', 'web'] | None
Parse
/restartarguments into a target (None: same interface).
- gptme.tools.restart.prepare_web_switch(conversation_name: str) str
Check the web UI can open this conversation and return its URL.
Raises RestartError (changing nothing) if no gptme-server is reachable, it doesn’t serve the web UI, or it can’t serve this conversation with the credentials the browser will get.
- gptme.tools.restart.restart_hook(messages: list[Message], **kwargs) Generator[Message, None, None]
Hook that detects restart tool call and performs the restart.
Runs at GENERATION_PRE (before generating response) to restart immediately after the restart tool is called.
By this point, all messages (including the assistant’s restart message and the system confirmation) have been saved to the log.