feat(chat): add WebUI prefill script hook#2888
Conversation
|
Follow-up hardening pushed in
Design note: the legacy Verification:
|
SummaryRead the PR diff against Code reference
def _load_prefill_messages_script(config_data: dict) -> dict:
script_raw = os.getenv("HERMES_WEBUI_PREFILL_MESSAGES_SCRIPT", "") or config_data.get("webui_prefill_messages_script")
if not script_raw:
return _prefill_not_configured()
...
proc = subprocess.run(command, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
timeout=_prefill_script_timeout(config_data), check=False)And Diagnosis / review notesA few things worth tightening before merge: 1. The "legacy 2. Path-resolution inconsistency between string and list config shapes. parts = shlex.split(str(raw or ""))
if not parts: return []
if len(parts) == 1:
parts[0] = str(_resolve_prefill_path(parts[0]))
return partsSo 3. Per-turn subprocess on the SSE hot path. This runs on every browser-originated turn before the SSE stream opens ( 4. No environment scrub. Test planThe new tests in Solid PR overall. None of the above are blockers; #1 (docstring framing) and #2 (path resolution) are worth a quick follow-up commit. |
|
Thanks for the contribution @AJV20! Holding this PR for now while we work through a few concerns from the automated triage pass (see previous comment). Specific things we'd like to see before merging:
Happy to chat through any of these in the comments if helpful. The general feature direction is fine — we just want the safety rails in before it lands on the streaming path. |
08e9ce3
# Conflicts: # CHANGELOG.md # tests/test_webui_prefill_context.py
Thinking Path
prefill_messages_filecontext for browser-originated turns.What Changed
webui_prefill_messages_scriptandHERMES_WEBUI_PREFILL_MESSAGES_SCRIPTsupport inapi/streaming.py.prefill_messages_scriptignored by WebUI unless the new WebUI-specific key is used.messageslistsystemprefill messagewebui_prefill_messages_script_timeout/HERMES_WEBUI_PREFILL_MESSAGES_SCRIPT_TIMEOUTwith a 5s default and 30s cap.README.mdandARCHITECTURE.md.CHANGELOG.mdentry.Why It Matters
This lets users keep WebUI context parity with other Hermes surfaces when their environment uses a local recall script for third-party notes or knowledge sources. It stays provider-agnostic and default-off rather than hard-coding Joplin or any one notes system into WebUI.
Verification
python3.11 -m py_compile api/streaming.pypython3.11 -m pytest tests/test_webui_prefill_context.py -q -o addopts=— 8 passedgit diff --checkRisks / Follow-ups