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

+69
View File
@@ -142,3 +142,72 @@ def test_gateway_humanize_keeps_wrapper_when_result_only_off():
service = build_service(llm, {"humanize": {"enabled": True}, "simplex": {}})
service._reply("simplex", "c", "track.manual: ok — sent", kind="result")
assert service.outbound["simplex"].get_nowait().text == "Done."
# ---- per-skill override (the skill's own config.json) ----
class FakeStore:
"""Stands in for the scheduler's `body_store` (SkillStore)."""
def __init__(self, configs):
self.configs = configs # {(category, name): {...}}
def read_config(self, category, name):
return self.configs.get((category, name), {})
class FakeSchedulerWithStore(FakeScheduler):
def __init__(self, llm, store):
super().__init__(llm)
self.body_store = store
def build_service_with_store(llm, config, store):
return GatewayService(
FakeSchedulerWithStore(llm, store), FakeAdapter(), config=config
)
def test_gateway_skill_config_disables_humanize():
"""A skill whose own config sets humanize:false is not cleaned up, even
when the platform/global default is on."""
llm = FakeClient(reply="should not be used")
store = FakeStore({("time", "now"): {"humanize": False}})
service = build_service_with_store(
llm, {"humanize": {"enabled": True}, "simplex": {}}, store
)
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
assert service.outbound["simplex"].get_nowait().text == "time.now: ok — 12:00"
assert llm.calls == []
def test_gateway_skill_config_enables_humanize_over_platform():
"""A skill's own humanize:true wins over a disabled platform/global default."""
llm = FakeClient(reply="It is 12:00.")
store = FakeStore({("time", "now"): {"humanize": True}})
service = build_service_with_store(
llm,
{"humanize": {"enabled": False}, "simplex": {"humanize": False}},
store,
)
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
assert service.outbound["simplex"].get_nowait().text == "It is 12:00."
def test_gateway_skill_config_absent_falls_back_to_platform():
"""No skill override -> the platform/global default applies."""
llm = FakeClient(reply="It is 12:00.")
store = FakeStore({})
service = build_service_with_store(
llm, {"humanize": {"enabled": True}, "simplex": {}}, store
)
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
assert service.outbound["simplex"].get_nowait().text == "It is 12:00."
def test_skill_ref_parses_summary_and_resumed_marker():
from semif_agent.gateway.service import _skill_ref
assert _skill_ref("time.now: ok — 12:00") == "time.now"
assert _skill_ref("[resumed] track.manual: ok — sent") == "track.manual"
assert _skill_ref("queued") is None
+73 -5
View File
@@ -768,13 +768,14 @@ def test_navigate_category_options_carry_descriptions(tmp_path):
def test_navigate_category_rejected_scope_authors_category(tmp_path):
"""The confirm guard is the category create door: a softmax winner whose
scope the guard rejects authors a new category."""
scope the guard rejects authors a new category. The winner is below
`softmax_bypass_tau`, so the guard actually runs."""
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
trace = TraceLog(str(tmp_path / "runs.jsonl"))
tree = _leaf_tree()
engine = _ProbEngine(
{
"top-level category": {"simplex": 1.0},
"top-level category": {"simplex": 0.45},
"Does the scope": {"none": 1.0},
}
)
@@ -785,12 +786,12 @@ def test_navigate_category_rejected_scope_authors_category(tmp_path):
def test_navigate_category_confirmed_scope_descends(tmp_path):
"""A softmax winner the guard confirms is descended into (no create)."""
"""A below-threshold softmax winner the guard confirms is descended into."""
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
trace = TraceLog(str(tmp_path / "runs.jsonl"))
engine = _ProbEngine(
{
"top-level category": {"simplex": 1.0},
"top-level category": {"simplex": 0.45},
"Does the scope": {"covers": 1.0},
"skill performs": {"next_message": 1.0, "connect_link": 0.0},
}
@@ -801,6 +802,26 @@ def test_navigate_category_confirmed_scope_descends(tmp_path):
assert any(e["kind"] == "category_scope" and e["fits"] for e in trace.read())
def test_navigate_confident_category_winner_skips_scope_confirm(tmp_path):
"""A category softmax winner at/above `softmax_bypass_tau` is decisive: the
scope confirm is not called (no `navigate:category_scope` decision)."""
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
trace = TraceLog(str(tmp_path / "runs.jsonl"))
engine = _ProbEngine(
{
"top-level category": {"simplex": 0.9},
"skill performs": {"next_message": 1.0, "connect_link": 0.0},
}
)
result = navigate(engine, log, trace, Request("read a message"), _leaf_tree())
assert getattr(result, "name", None) == "next_message"
assert any(e["kind"] == "category_scope_bypassed" for e in trace.read())
assert not any(e["kind"] == "category_scope" for e in trace.read())
assert all("Does the scope" not in c.question for c in engine.calls)
phases = [r["extra"].get("phase") for r in log.read()]
assert "navigate:category_scope" not in phases
def test_confirm_category_fit_threshold(tmp_path):
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
trace = TraceLog(str(tmp_path / "runs.jsonl"))
@@ -994,7 +1015,8 @@ def test_dispatch_intent_tau_controls_reuse_vs_create(tmp_path):
{
"top-level category": {"simplex": 1.0},
"Does the scope": {"covers": 1.0},
"skill performs": {"next_message": 1.0, "connect_link": 0.0},
# Below softmax_bypass_tau (0.5), so the intent guard runs.
"skill performs": {"next_message": 0.45, "connect_link": 0.3},
"same action": {"same": 0.8, "different": 0.2},
}
)
@@ -1105,6 +1127,52 @@ def test_dispatch_intent_match_runs_skill(tmp_path):
assert result.skill == "next_message"
def test_dispatch_confident_leaf_winner_skips_intent_guard(tmp_path):
"""A leaf softmax winner at/above `softmax_bypass_tau` skips the intent
confirm: the guard would reject here (same action = different), but a
decisive softmax runs the skill instead."""
engine = _ProbEngine(
{
"top-level category": {"simplex": 1.0},
"skill performs": {"next_message": 0.9, "connect_link": 0.1},
"same action": {"different": 1.0},
}
)
scheduler = Scheduler(
engine=engine,
llm=LLMClient(base_url="http://localhost:1/v1", model="test"),
log=DecisionLog(str(tmp_path / "decisions.jsonl")),
config={
"skills": {},
"category_registry": str(tmp_path / "categories.json"),
"skill_bodies": str(tmp_path / "skills"),
"skill_seeds": str(tmp_path / "seeds"),
},
trace=TraceLog(str(tmp_path / "runs.jsonl")),
)
def act(ctx, request):
return ActionResult(action_log="read fixture", new_state="read")
scheduler.tree = {
"simplex": [
Skill(
name="next_message",
category="simplex",
description="Read the next SimpleX message.",
act=act,
),
Skill(name="connect_link", category="simplex", description="Show the contact link."),
]
}
result = scheduler._dispatch(Request("read the next simplex message"))
assert result.kind == "ran"
assert result.skill == "next_message"
assert any(e["kind"] == "intent_bypass" for e in scheduler.trace.read())
phases = [r["extra"].get("phase") for r in scheduler.log.read()]
assert "navigate:intent" not in phases
def test_dispatch_create_category_queues_draft_and_is_not_fatal(tmp_path):
"""An empty tree short-circuits to CreateCategory; the `llm` draft is