From 41bd98309d44ee5c730b3dca535636da1a2e5dff Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 22:26:23 -0700 Subject: [PATCH] refactor(honcho): compact tool/config schema literals (dumps byte-identical) --- plugins/memory/honcho/config_schema.py | 51 ++++---------- plugins/memory/honcho/tool_schemas.py | 94 ++++++++------------------ 2 files changed, 43 insertions(+), 102 deletions(-) diff --git a/plugins/memory/honcho/config_schema.py b/plugins/memory/honcho/config_schema.py index 69800f7cea..adb1334fd5 100644 --- a/plugins/memory/honcho/config_schema.py +++ b/plugins/memory/honcho/config_schema.py @@ -1,16 +1,8 @@ """Honcho's declared config surface — rendered by the generic desktop panel.""" from plugins.memory.config_schema import ( - KIND_BOOL, - KIND_JSON, - KIND_NUMBER, - KIND_SECRET, - KIND_SELECT, - KIND_TEXT, - STORAGE_HONCHO_HOST_BLOCK, - ProviderConfigSchema, - ProviderField, - ProviderFieldOption, + KIND_BOOL, KIND_JSON, KIND_NUMBER, KIND_SECRET, KIND_SELECT, KIND_TEXT, STORAGE_HONCHO_HOST_BLOCK, + ProviderConfigSchema, ProviderField, ProviderFieldOption, ) @@ -21,22 +13,13 @@ def _opts(*pairs: tuple[str, str]) -> tuple[ProviderFieldOption, ...]: # Reasoning effort levels shared by dialectic-related selects. _REASONING_LEVELS = _opts(("minimal", "Minimal"), ("low", "Low"), ("medium", "Medium"), ("high", "High"), ("max", "Max")) -_SESSION_STRATEGY_INFO = ( - "Per session: every conversation gets its own Honcho session. " - "Per directory: conversations from the same working directory share one. " - "Per repo: conversations from the same git repo share one. " - "Global: everything shares a single session." -) -_WRITE_FREQUENCY_INFO = ( - "async: write in the background as messages arrive. " - "turn: flush after each turn. session: flush when the session ends. " - "A number N flushes every N turns." -) -_RECALL_MODE_INFO = ( - "Hybrid: auto-injected context plus on-demand memory tools. " - "Context only: injection without tools. " - "Tools only: the model queries memory explicitly, nothing is injected." -) +_SESSION_STRATEGY_INFO = ("Per session: every conversation gets its own Honcho session. " + "Per directory: conversations from the same working directory share one. " + "Per repo: conversations from the same git repo share one. Global: everything shares a single session.") +_WRITE_FREQUENCY_INFO = ("async: write in the background as messages arrive. turn: flush after each turn. " + "session: flush when the session ends. A number N flushes every N turns.") +_RECALL_MODE_INFO = ("Hybrid: auto-injected context plus on-demand memory tools. Context only: injection without tools. " + "Tools only: the model queries memory explicitly, nothing is injected.") def _field(key, label, kind, description, *, group, **kw) -> ProviderField: @@ -68,16 +51,13 @@ CONFIG_SCHEMA = ProviderConfigSchema( inline=True, group="Identity"), # — Session (inline) — _field("sessionStrategy", "Session strategy", KIND_SELECT, "How conversations map to Honcho sessions.", - default="per-directory", info=_SESSION_STRATEGY_INFO, - options=_opts(("per-session", "Per session"), ("per-directory", "Per directory"), - ("per-repo", "Per repo"), ("global", "Global")), - inline=True, group="Session"), + default="per-directory", info=_SESSION_STRATEGY_INFO, inline=True, group="Session", + options=_opts(("per-session", "Per session"), ("per-directory", "Per directory"), ("per-repo", "Per repo"), ("global", "Global"))), # — Connection — _field("timeout", "Request timeout", KIND_NUMBER, "Request timeout in seconds for Honcho HTTP calls. Blank uses the default.", aliases=("requestTimeout",), env_fallbacks=("HONCHO_TIMEOUT",), placeholder="30", group="Connection", scope="root"), # — Identity — - _field("pinUserPeer", "Pin user peer", KIND_BOOL, - "Pin the user peer to the peer name, ignoring gateway runtime identity. Unifies memory for single-user setups.", + _field("pinUserPeer", "Pin user peer", KIND_BOOL, "Pin the user peer to the peer name, ignoring gateway runtime identity. Unifies memory for single-user setups.", default="false", aliases=("pinPeerName",), group="Identity"), _field("runtimePeerPrefix", "Runtime peer prefix", KIND_TEXT, "Prefix applied to unknown gateway runtime user IDs.", placeholder="e.g. telegram_", group="Identity"), @@ -116,14 +96,13 @@ CONFIG_SCHEMA = ProviderConfigSchema( options=_opts(("hybrid", "Hybrid"), ("context", "Context only"), ("tools", "Tools only")), group="Recall"), _field("contextTokens", "Context token cap", KIND_NUMBER, "Cap on auto-injected context tokens. Blank leaves it uncapped.", placeholder="(uncapped)", 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"), + _field("initOnSessionStart", "Eager init", KIND_BOOL, "Initialize the session eagerly in tools mode instead of on first tool call.", + default="false", group="Recall"), # — Limits — _field("messageMaxChars", "Message max chars", KIND_NUMBER, "Max chars per message sent to Honcho.", placeholder="25000", group="Limits"), # — Observation — - _field("observationMode", "Observation mode", KIND_SELECT, - "Per-peer observation preset. Directional observes all directions; unified shares one view.", + _field("observationMode", "Observation mode", KIND_SELECT, "Per-peer observation preset. Directional observes all directions; unified shares one view.", default="directional", options=_opts(("directional", "Directional"), ("unified", "Unified")), group="Observation"), ), ) diff --git a/plugins/memory/honcho/tool_schemas.py b/plugins/memory/honcho/tool_schemas.py index e3780fd8a7..d109028543 100644 --- a/plugins/memory/honcho/tool_schemas.py +++ b/plugins/memory/honcho/tool_schemas.py @@ -3,18 +3,13 @@ Profile / search / reasoning / context / conclude, exposed via HonchoMemoryProvider.get_tool_schemas(). """ -_PEER = { - "type": "string", - "description": "Peer to query. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace.", -} +_PEER = {"type": "string", + "description": "Peer to query. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace."} def _tool(name: str, description: str, properties: dict, required: list) -> dict: - return { - "name": name, - "description": description, - "parameters": {"type": "object", "properties": properties, "required": required}, - } + return {"name": name, "description": description, + "parameters": {"type": "object", "properties": properties, "required": required}} PROFILE_SCHEMA = _tool( @@ -30,14 +25,9 @@ PROFILE_SCHEMA = _tool( "representation + summary + recent messages); honcho_search to find " "specific things that were actually said; honcho_reasoning for a " "synthesized answer to a question.", - { - "peer": _PEER, - "card": { - "type": "array", - "items": {"type": "string"}, - "description": "New peer card as a list of fact strings. Omit to read the current card.", - }, - }, + {"peer": _PEER, + "card": {"type": "array", "items": {"type": "string"}, + "description": "New peer card as a list of fact strings. Omit to read the current card."}}, [], ) @@ -52,20 +42,12 @@ SEARCH_SCHEMA = _tool( "'what was the regimen/decision/config we settled on' — and reason " "over the excerpts yourself. For nuanced questions needing synthesis, " "use honcho_reasoning instead.", - { - "query": { - "type": "string", - "description": "What to look for — a topic, keyword, name, or natural-language description of the fact you're trying to recall.", - }, - "max_tokens": { - "type": "integer", - "description": "Approximate budget for returned excerpts (default 800, max 2000). Larger budgets return more/longer ranked snippets.", - }, - "peer": { - "type": "string", - "description": "Whose history to search. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace. Spans every session that peer took part in.", - }, - }, + {"query": {"type": "string", + "description": "What to look for — a topic, keyword, name, or natural-language description of the fact you're trying to recall."}, + "max_tokens": {"type": "integer", + "description": "Approximate budget for returned excerpts (default 800, max 2000). Larger budgets return more/longer ranked snippets."}, + "peer": {"type": "string", + "description": "Whose history to search. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace. Spans every session that peer took part in."}}, ["query"], ) @@ -83,12 +65,8 @@ REASONING_SCHEMA = _tool( "honcho_profile / honcho_context (no LLM). " "Pass reasoning_level to control depth: minimal (fast/cheap), low (default), " "medium, high, max (deep/expensive). Omit for the configured default.", - { - "query": { - "type": "string", - "description": "A natural language question.", - }, - "reasoning_level": { + {"query": {"type": "string", "description": "A natural language question."}, + "reasoning_level": { "type": "string", "description": ( "Override the default reasoning depth. " @@ -113,10 +91,8 @@ REASONING_SCHEMA = _tool( "Default to at least 'low' unless the query is genuinely a single " "fact lookup." ), - "enum": ["minimal", "low", "medium", "high", "max"], - }, - "peer": _PEER, - }, + "enum": ["minimal", "low", "medium", "high", "max"]}, + "peer": _PEER}, ["query"], ) @@ -130,9 +106,7 @@ CONTEXT_SCHEMA = _tool( "search: to look up a specific past fact use honcho_search; to ask a " "question and get a synthesized answer use honcho_reasoning; for just the " "compact card use honcho_profile.", - { - "peer": _PEER, - }, + {"peer": _PEER}, [], ) @@ -151,28 +125,16 @@ CONCLUDE_SCHEMA = _tool( "Honcho self-heals contradictions over time. This is a WRITE tool: to read " "the profile use honcho_profile / honcho_context, and to search what was " "said use honcho_search.", - { - "conclusion": { - "type": "string", - "description": "A factual statement to persist. Provide this when creating a conclusion. Do not send it together with delete_id or list.", - }, - "delete_id": { - "type": "string", - "description": "Conclusion ID to delete for PII removal. Provide this when deleting a conclusion. Do not send it together with conclusion or list. Get this id from a prior `list` call — never guess it.", - }, - "list": { - "type": "boolean", - "description": "Set to true to list or search stored conclusions (with their ids) instead of creating or deleting one. Do not send together with conclusion or delete_id.", - }, - "query": { - "type": "string", - "description": "Optional semantic search query, used only when `list` is true. Omit to list the most recent conclusions instead of searching.", - }, - "peer": { - "type": "string", - "description": "The peer the conclusion is ABOUT. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace.", - }, - }, + {"conclusion": {"type": "string", + "description": "A factual statement to persist. Provide this when creating a conclusion. Do not send it together with delete_id or list."}, + "delete_id": {"type": "string", + "description": "Conclusion ID to delete for PII removal. Provide this when deleting a conclusion. Do not send it together with conclusion or list. Get this id from a prior `list` call — never guess it."}, + "list": {"type": "boolean", + "description": "Set to true to list or search stored conclusions (with their ids) instead of creating or deleting one. Do not send together with conclusion or delete_id."}, + "query": {"type": "string", + "description": "Optional semantic search query, used only when `list` is true. Omit to list the most recent conclusions instead of searching."}, + "peer": {"type": "string", + "description": "The peer the conclusion is ABOUT. Built-in aliases: 'user' (default), 'ai'. Or pass any peer ID from this workspace."}}, [], )