navigation: never bypass the leaf intent guard
The leaf softmax offers only existing skills (create_skill is deliberately
not an option), so a confident winner is "the closest existing skill", never
a statement that it matches. Skipping the intent guard on a confident leaf
softmax winner therefore made codegen unreachable for an unmatched request:
with Winnow as the engine, "send a message to pepper on SimpleX" picked
connect_link (0.86) / next_message (0.995), bypassed the guard, and ran a
read skill instead of authoring simplex.send_message.
Always run confirm_skill_fit at the leaf — it is the sole leaf-level create
door. The category scope bypass stays (create_category is one of its
options, so a confident category winner is meaningful). Drop the now-unused
leaf_softmax_prob meta plumbing; update the docs and the regression test.
Also fix a deployment-hostname leak ("guppy") in winnow.py's docstring that
tripped test_no_env_leaks.
This commit is contained in:
1 parent
ee7700275c
commit
f1e0de33ca
6 files changed
+56
-52
No files matched your search
+10
-18
@@ -248,9 +248,10 @@ class Scheduler:
|
||||
self.intent_tau = float(nav_cfg.get("intent_tau", 0.6))
|
||||
self.category_tau = float(nav_cfg.get("category_tau", 0.75))
|
||||
self.action_tau = float(nav_cfg.get("action_tau", 0.5))
|
||||
#: A softmax winner at or above this probability skips its confirm guard
|
||||
#: (scope/intent) — the winner is already decisive. Below it the guard
|
||||
#: runs and can reject into create.
|
||||
#: A **category** softmax winner at or above this probability skips the
|
||||
#: category scope confirm — the winner is already decisive. The leaf
|
||||
#: intent guard is never bypassed (the leaf softmax has no create
|
||||
#: option, so its confidence carries no match signal).
|
||||
self.bypass_tau = float(nav_cfg.get("softmax_bypass_tau", 0.5))
|
||||
self.max_reentries = max_reentries
|
||||
self.codegen = codegen
|
||||
@@ -456,10 +457,6 @@ class Scheduler:
|
||||
# ---- dispatch ----
|
||||
|
||||
def _dispatch(self, request: Request) -> DispatchResult:
|
||||
# Clear any confidence a prior dispatch left on the request (meta is
|
||||
# copied across a requeue); navigation sets it fresh when a leaf softmax
|
||||
# runs.
|
||||
request.meta.pop("leaf_softmax_prob", None)
|
||||
# Explicit housekeeping commands are deterministic: they route straight
|
||||
# to the meta skill, bypassing the generic guards (which misread a
|
||||
# task-like skill name as the task). Natural-language phrasings still go
|
||||
@@ -501,17 +498,12 @@ class Scheduler:
|
||||
# navigation's pick directly (the meta skill asks for any missing
|
||||
# target as an input variable).
|
||||
return self._run_skill(navigation, request)
|
||||
leaf_prob = request.meta.pop("leaf_softmax_prob", None)
|
||||
if leaf_prob is not None and leaf_prob >= self.bypass_tau:
|
||||
# A decisive leaf softmax winner skips the intent confirm.
|
||||
self.trace.append(
|
||||
"intent_bypass",
|
||||
request.id,
|
||||
category=navigation.category,
|
||||
skill=navigation.name,
|
||||
prob=leaf_prob,
|
||||
)
|
||||
return self._run_skill(navigation, request)
|
||||
# The leaf softmax offers only existing skills (create_skill is
|
||||
# deliberately not an option), so its winner is "the closest existing
|
||||
# skill", never a statement that the skill matches. The intent guard is
|
||||
# therefore the sole leaf-level create door and is never bypassed: a
|
||||
# confident softmax winner among only-wrong options must still be
|
||||
# checked, or codegen can never be reached for an unmatched request.
|
||||
if not confirm_skill_fit(
|
||||
self.engine, self.log, self.trace, request, navigation, self.intent_tau
|
||||
):
|
||||
|
||||
+16
-14
@@ -1171,17 +1171,22 @@ def navigate(
|
||||
) -> Skill | CreateCategory | CreateSkill:
|
||||
"""Descend the tree one SemIf choice per level. Every choice is logged.
|
||||
|
||||
**Confident softmax winners skip their confirm guard.** When the category
|
||||
softmax winner's probability is >= `bypass_tau` (default 0.5) the scope
|
||||
confirm (`confirm_category_fit`) is skipped — the winner is taken as-is
|
||||
(traced `category_scope_bypassed`); below it the guard runs and can reject
|
||||
the winner into create. The leaf softmax winner's probability is handed to
|
||||
dispatch (`request.meta["leaf_softmax_prob"]`) so `confirm_skill_fit` is
|
||||
likewise skipped above the threshold (traced `intent_bypass`). The guards
|
||||
exist to catch an unsure softmax; a winner at 0.5+ is already decisive, and
|
||||
each skipped guard is one fewer SemIf call on the hot path. Below the
|
||||
threshold the two-stage behavior is unchanged. The recorded data agrees:
|
||||
every logged winner >= 0.5 also passed its guard.
|
||||
**A confident category winner skips the scope confirm; the leaf intent
|
||||
guard always runs.** When the category softmax winner's probability is >=
|
||||
`bypass_tau` (default 0.5) the scope confirm (`confirm_category_fit`) is
|
||||
skipped — the winner is taken as-is (traced `category_scope_bypassed`). That
|
||||
is sound because `create_category` is one of the category softmax options, so
|
||||
a confident winner genuinely beat "author a new category"; below the threshold
|
||||
the guard runs and can reject the winner into create. The leaf softmax has
|
||||
**no** create option (`create_skill` is deliberately absent), so its
|
||||
probabilities are renormalized over only the existing skills and a confident
|
||||
winner means "best of the wrong lot", not a match. The leaf intent guard
|
||||
(`confirm_skill_fit`) is therefore **never** bypassed: it is the sole
|
||||
leaf-level create door, and skipping it would make codegen unreachable for an
|
||||
unmatched request. (Regression: with Winnow as the engine, "send a message to
|
||||
pepper on SimpleX" picked `connect_link` at 0.86 / `next_message` at 0.995,
|
||||
skipped the guard, and ran a read skill instead of authoring
|
||||
`simplex.send_message`.)
|
||||
|
||||
The **actionability guard** (`confirm_non_action`, phase
|
||||
`navigate:actionability`, keyed by `navigation.action_tau`) runs at the **top**
|
||||
@@ -1333,9 +1338,6 @@ def navigate(
|
||||
leaf_result = engine.call(leaf)
|
||||
log.append(leaf, leaf_result, extra={"phase": "navigate:leaf", "run_id": request.id})
|
||||
pick = leaf_result.selected
|
||||
# Hand the winner's confidence to dispatch so it can skip the intent guard
|
||||
# when the softmax is already decisive (see `navigate` docstring).
|
||||
request.meta["leaf_softmax_prob"] = float(leaf_result.probs.get(pick, 0.0))
|
||||
return next((s for s in skills if s.name == pick), skills[0])
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ and the question becomes its ``instructions``; the server returns a probability
|
||||
over exactly those keys.
|
||||
|
||||
Winnow runs as its own process (``winnow-server``); see ``local/ENVIRONMENT.md``
|
||||
for the guppy deployment. The engine is real: any network, HTTP, or distribution
|
||||
for this deployment. The engine is real: any network, HTTP, or distribution
|
||||
failure raises `EngineUnavailable`, which the scheduler treats as fatal — there
|
||||
is no fallback model and no fabricated reply.
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user