fix(honcho): declare the injection block in config_schema so the desktop panel can pin sessionStart

The generic panel writes every field flat, and the plugin reads `injection` as one object, so a dotted `injection.sessionStart` field would never be read. Declare `injection` as a JSON field instead. Blank clears the pin.
This commit is contained in:
Erosika
2026-09-10 10:41:50 -04:00
committed by kshitij
parent 29113b24d8
commit c04722102f
2 changed files with 21 additions and 0 deletions

View File

@@ -105,6 +105,11 @@ CONFIG_SCHEMA = ProviderConfigSchema(
default="false", group="Recall"),
_field("contextTokens", "Context token cap", KIND_NUMBER, "Cap on auto-injected context tokens. Blank leaves it uncapped.",
placeholder="(uncapped)", group="Recall"),
# The plugin reads `injection` as one object, so the panel edits the whole block rather than a nested key.
_field("injection", "Session-start injection", KIND_JSON,
"Pin which base-context sections the first turn injects: summary, peerRepresentation, peerCard, "
"aiRepresentation, aiCard. Blank injects all of them; an empty list injects nothing.",
placeholder='{"sessionStart": ["summary", "peerCard"]}', group="Recall"),
_field("initOnSessionStart", "Eager init", KIND_BOOL, "Initialize the session eagerly in tools mode instead of on first tool call.",
default="false", group="Recall"),
# — Limits —

View File

@@ -1317,6 +1317,22 @@ class TestSessionStartInjection:
formatted = _provider_with_raw(raw)._format_first_turn_context(_FULL_CTX)
assert [line for line in formatted.splitlines() if line.startswith("## ")] == headings
@pytest.mark.parametrize("submitted, headings", [
('{"sessionStart": ["peerCard"]}', ["## User Peer Card"]),
('{"sessionStart": []}', []),
("", ["## Session Summary", "## User Representation", "## User Peer Card",
"## AI Self-Representation", "## AI Identity Card"]),
], ids=["pin", "empty-list", "blank-clears-the-pin"])
def test_desktop_panel_writes_the_pin_the_provider_reads(self, submitted, headings):
from hermes_cli.web_routers.memory_providers import _apply_field_values
from plugins.memory.honcho.config_schema import CONFIG_SCHEMA
host_block = {"injection": {"sessionStart": ["summary"]}}
_apply_field_values(CONFIG_SCHEMA, {"injection": submitted}, lambda field: host_block)
raw = {"hosts": {"hermes": host_block}}
formatted = _provider_with_raw(raw)._format_first_turn_context(_FULL_CTX)
assert [line for line in formatted.splitlines() if line.startswith("## ")] == headings
def test_non_list_value_is_treated_as_unset(self):
raw = {"injection": {"sessionStart": "summary"}}
assert _provider_with_raw(raw)._session_start_components is None