navigation: skip confirms on a confident softmax; per-skill humanize; 500ms VAD

Four latency/ergonomics changes from the voice-gateway diagnosis:

1. Per-skill humanize override. A skill's own recorded config
   (data/skills/<cat>/<name>/config.json -> {"humanize": bool}) now wins over
   the per-platform and global defaults, so an already-speakable result
   (time.now) can skip the rewrite. The gateway resolves the skill ref from the
   result summary; `_finish_run` now emits `category.name: ok — …` (matching the
   assessment summary) so the ref is available. Missing store/config/key and
   test doubles degrade to the existing platform/global behavior.

2. Example voice endpointing: vad.silence_ms 1000 -> 500 (config.example.json).

3. Confident softmax winners skip their confirm guard. New
   navigation.softmax_bypass_tau (default 0.5): a category winner at/above it
   skips confirm_category_fit (trace `category_scope_bypassed`); a leaf winner
   at/above it is handed to dispatch and skips confirm_skill_fit (trace
   `intent_bypass`). Below the threshold the two-stage confirm is unchanged.
   Assumption tested first on the decision log: 28/28 category and 28/28 leaf
   winners >= 0.5 agreed with their guard.

4. Engine-throughput investigation saved to AGENTS.md "Later / open questions"
   (routing/assessment compute dominates; profile the engine, not the audio).

Tests updated for the bypass threshold and added for the skill-level humanize
override and bypass paths. Full suite: 486 passed, 1 skipped.
This commit is contained in:
gabby committed 2026-10-06 22:33:38 +00:00
1 parent 5bb0e9d21d
commit d0c1dccffd
7 files changed
+256 -16

No files matched your search

+46 -5
View File
@@ -31,6 +31,13 @@ from .humanize import Humanizer
_LEADING_RUN_ID = re.compile(r"^\[[0-9a-f]{6,}\]\s*")
#: A result summary starts with the skill ref (`category.name:`), optionally
#: preceded by a `[resumed]` marker. Used to look up a skill's own config
#: (`data/skills/<cat>/<name>/config.json`) for a per-skill humanize override.
_SKILL_REF = re.compile(
r"^(?:\[resumed\]\s*)?([A-Za-z0-9_][A-Za-z0-9_-]*\.[A-Za-z0-9_][A-Za-z0-9_-]*):\s"
)
#: The scheduler's run summary wraps the real result as
#: `"<skill>: <ok|failed> — <detail>"`. A result-only platform (the voice
#: gateway) speaks just `<detail>`.
@@ -66,6 +73,12 @@ def _strip_run_id(text: str) -> str:
return _LEADING_RUN_ID.sub("", text or "")
def _skill_ref(text: str) -> str | None:
"""The `category.name` a result summary belongs to, or None."""
match = _SKILL_REF.match(text or "")
return match.group(1) if match else None
def _leading_run_id(text: str) -> str:
match = _LEADING_RUN_ID.match(text or "")
return match.group(0)[1:-2] if match else ""
@@ -202,14 +215,19 @@ class GatewayService:
max_chars=int(cfg.get("max_chars", 600)),
)
def _humanize_enabled(self, platform: str) -> bool:
"""Whether this platform cleans up its result line.
def _humanize_enabled(self, platform: str, skill_ref: str | None = None) -> bool:
"""Whether this result is cleaned up.
A per-platform `humanize` bool (or `{enabled: bool}`) overrides the
global `gateway.humanize.enabled`. Default is off.
Precedence: the **skill's own config** (`data/skills/<category>/<name>/
config.json` -> `{"humanize": bool}`) wins; otherwise the per-platform
override (`gateway.<platform>.humanize`), otherwise the global default
(`gateway.humanize.enabled`). A missing `llm` client disables it.
"""
if self.humanizer is None:
return False
skill_override = self._skill_humanize_override(skill_ref)
if skill_override is not None:
return skill_override
override = self._platform_cfg.get(platform, {}).get("humanize")
if isinstance(override, bool):
return override
@@ -217,6 +235,28 @@ class GatewayService:
return bool(override["enabled"])
return self._humanize_default
def _skill_humanize_override(self, skill_ref: str | None) -> bool | None:
"""The skill's own `humanize` config value, or None when unset.
A skill opts in/out of result cleanup regardless of the platform default
via its recorded config: `data/skills/<category>/<name>/config.json` ->
`{"humanize": false}`. Read from the scheduler's skill store; a missing
store/config/key (or an unparseable ref) means no override.
"""
if not skill_ref or "." not in skill_ref:
return None
store = getattr(self.scheduler, "body_store", None)
if store is None:
return None
category, name = skill_ref.split(".", 1)
try:
config = store.read_config(category, name) or {}
except Exception:
return None
if "humanize" in config:
return bool(config["humanize"])
return None
def _fallback_target(self) -> Target | None:
for platform in self.platforms:
home = self._home_channel(platform)
@@ -438,7 +478,8 @@ class GatewayService:
) -> None:
text = _strip_run_id(text)
result_only = self._result_only(platform)
humanize = kind == "result" and self._humanize_enabled(platform)
skill_ref = _skill_ref(text) if kind == "result" else None
humanize = kind == "result" and self._humanize_enabled(platform, skill_ref)
if result_only:
# A spoken front end says the skill's result, not the scheduler's
# bookkeeping: drop queue/urgency chatter.