feat: personality

This commit is contained in:
Austin Pickett 2026-04-08 00:15:15 -04:00
parent ebd2d83ef2
commit 371efafc46
3 changed files with 18 additions and 2 deletions

View file

@ -319,9 +319,13 @@ def _wire_callbacks(sid: str):
def _make_agent(sid: str, key: str, session_id: str | None = None): def _make_agent(sid: str, key: str, session_id: str | None = None):
from run_agent import AIAgent from run_agent import AIAgent
cfg = _load_cfg()
system_prompt = cfg.get("agent", {}).get("system_prompt", "") or ""
return AIAgent( return AIAgent(
model=_resolve_model(), quiet_mode=True, platform="tui", model=_resolve_model(), quiet_mode=True, platform="tui",
session_id=session_id or key, session_db=_get_db(), **_agent_cbs(sid), session_id=session_id or key, session_db=_get_db(),
ephemeral_system_prompt=system_prompt or None,
**_agent_cbs(sid),
) )
@ -1119,6 +1123,11 @@ def _mirror_slash_side_effects(sid: str, session: dict, command: str):
api_mode=result.api_mode, api_mode=result.api_mode,
) )
_emit("session.info", sid, _session_info(agent)) _emit("session.info", sid, _session_info(agent))
elif name in ("personality", "prompt") and agent:
cfg = _load_cfg()
new_prompt = cfg.get("agent", {}).get("system_prompt", "") or ""
agent.ephemeral_system_prompt = new_prompt or None
agent._cached_system_prompt = None
elif name == "compress" and agent: elif name == "compress" and agent:
(getattr(agent, "compress_context", None) or getattr(agent, "context_compressor", agent).compress)() (getattr(agent, "compress_context", None) or getattr(agent, "context_compressor", agent).compress)()
elif name == "reload-mcp" and agent and hasattr(agent, "reload_mcp_tools"): elif name == "reload-mcp" and agent and hasattr(agent, "reload_mcp_tools"):

View file

@ -12,6 +12,7 @@ import sys
import cli as cli_mod import cli as cli_mod
from cli import HermesCLI from cli import HermesCLI
from rich.console import Console
def _run(cli: HermesCLI, command: str) -> str: def _run(cli: HermesCLI, command: str) -> str:
@ -22,6 +23,12 @@ def _run(cli: HermesCLI, command: str) -> str:
cmd = f"/{cmd}" cmd = f"/{cmd}"
buf = io.StringIO() buf = io.StringIO()
# Rich Console captures its file handle at construction time, so
# contextlib.redirect_stdout won't affect it. Swap the console's
# underlying file to our buffer so self.console.print() is captured.
cli.console = Console(file=buf, force_terminal=True, width=120)
old = getattr(cli_mod, "_cprint", None) old = getattr(cli_mod, "_cprint", None)
if old is not None: if old is not None:
cli_mod._cprint = lambda text: print(text) cli_mod._cprint = lambda text: print(text)

View file

@ -842,7 +842,7 @@ export function App({ gw }: { gw: GatewayClient }) {
return true return true
default: default:
rpc('slash.exec', { command: cmd.slice(1), session_id: sid }) gw.request('slash.exec', { command: cmd.slice(1), session_id: sid })
.then((r: any) => { .then((r: any) => {
if (r?.output) { if (r?.output) {
sys(r.output) sys(r.output)