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:
@@ -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 —
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user