routing: send unlearned actions to codegen, fix gate + repair loop

SemIf routing only sees option descriptions, but the leaf fallback said
'Suggest creating a new skill' (mechanism, not trigger), so a send request
had no verb match and fell through to the read skill that shared the word
'message'. Every send phrasing picked simplex.next_message; create_skill
scored ~0.03 and codegen was never reached.

- navigate: reword the create_skill fallback to the trigger ('No existing
  skill performs this action') and make the criterion ask which skill
  performs the requested action. Sends now route to create_skill at P~0.93.
- confirm_skill_fit: one action-vs-action SemIf guard (phase navigate:intent)
  after routing; a mismatch authors a new leaf instead of silently running the
  wrong skill. Wording tuned on the real model (no IM hint: it over-fires).
- gate: imperative tasks are actionable even with no matching skill, so a
  casually phrased send is no longer dropped as 'no actionable request'.
- finish_run: a failure whose retry is refused by the reentry budget still
  surfaces a repair offer.

Validated on jarvis: gate accepts all tasks/rejects all noise, sends route to
CreateSkill, reads still route to their skills. Dev: 265 passed; jarvis
non-codegen integration: 6 passed.
This commit is contained in:
Denton Social committed 2026-09-28 20:34:59 -05:00
1 parent 5589358de2
commit 13a512cc31
4 files changed
+294 -15

No files matched your search

+20 -7
View File
@@ -46,6 +46,7 @@ from .skills import (
build_skills,
build_tree,
compose_state,
confirm_skill_fit,
generate_category,
generate_skill,
materialize_skill,
@@ -82,10 +83,10 @@ def build_gate_decision(request: Request, tree: dict[str, list[Skill]]) -> Decis
capabilities = tree_summary(tree)[:GATE_CAPABILITY_CHARS] or " (none yet)"
state = (
f"User input: {request.text}\n"
"[Context: the user is talking to a personal task agent and expects it to "
"handle this input. The agent performs real tasks through its skills; "
"reading or looking up information from a configured service is a real "
"task, not small talk.]\n"
"[Context: the user is talking to a personal task agent. Any imperative "
"request to perform a task — send, message, tell, check, create, remind, "
"or look something up — must be handled, even if no skill matches yet. "
"Only chatter, thanks, and bare greetings should be ignored.]\n"
f"[Available skills:\n{capabilities}]"
)
return DecisionRequest(
@@ -94,8 +95,8 @@ def build_gate_decision(request: Request, tree: dict[str, list[Skill]]) -> Decis
options=[
Option(
GATE_YES,
"Yes — do what it asks, including looking something up or "
"reporting information using the agent's skills.",
"Yes — do what it asks, including looking something up, reporting "
"information, or performing an action using the agent's skills.",
),
Option(
"no",
@@ -462,6 +463,16 @@ class Scheduler:
return self._dispatch_skill(request, created.skill, weight)
if isinstance(navigation, CreateSkill):
return self._dispatch_skill(request, navigation.category, weight)
if not confirm_skill_fit(
self.engine, self.log, self.trace, request, navigation, self.tau
):
self.trace.append(
"intent_mismatch",
request.id,
selected_skill=f"{navigation.category}.{navigation.name}",
chosen="create_skill",
)
return self._dispatch_skill(request, navigation.category, weight)
return self._run_skill(navigation, request)
def _dispatch_skill(
@@ -633,13 +644,15 @@ class Scheduler:
action_log=outcome.action_log,
updated_request=outcome.updated_request,
)
requeued = False
if outcome.updated_request and request.reentries < self.max_reentries:
child = _requeue(request, outcome.updated_request)
self.queue.push(child, 0.5)
self.trace.append("requeued", request.id, text=outcome.updated_request)
if self.on_request_requeued is not None:
self.on_request_requeued(request.id, child.id)
if not outcome.success and not outcome.updated_request:
requeued = True
if not outcome.success and not (outcome.updated_request and requeued):
self._propose_repair(skill, request, outcome)
return DispatchResult(
kind="ran",
+64 -2
View File
@@ -574,10 +574,14 @@ def navigate(
)
return CreateCategory()
skills = tree[category]
create_skill = Option("create_skill", "Suggest creating a new skill.")
create_skill = Option(
"create_skill",
"No existing skill performs this action; create a new skill for it.",
)
leaf = DecisionRequest(
state=compose_state(request, current=category),
question=f"Within {category}, which skill?",
question=f"Which {category} skill performs the action this request asks for? "
"Choose create_skill if none does.",
options=[Option(s.name, s.description) for s in skills] + [create_skill],
)
if not skills:
@@ -610,6 +614,64 @@ def navigate(
return next(s for s in skills if s.name == pick)
def confirm_skill_fit(
engine: SemIfEngine,
log: DecisionLog,
trace: TraceLog,
request: Request,
skill: Skill,
tau: float = 0.6,
) -> bool:
"""Does this skill's action actually match what the request asks for?
Navigation picks the closest leaf; a seeded read skill can outscore the
generic "create a new skill" branch on a request whose verb (send) no
existing action performs. This one SemIf decision guards against silently
running the wrong skill: a mismatch sends dispatch to author a new leaf
instead. Wording tuned against the real model: comparing the two *actions*
("different action") is unambiguous where "can this serve the request" was
not — e.g. "message Sam" (an implicit send in instant-messaging syntax)
reads as a different action from "read the next message". Do not add an
instant-messaging context hint: it over-fires and pulls read phrasings to
the send side.
"""
decision = DecisionRequest(
state=(
f"Requested action: {request.text}\n"
f"Action of the existing skill: {skill.description}"
),
question="Compare the requested action and the skill's action. Are they the same action?",
options=[
Option("same", "Same action."),
Option(
"different",
"Different action: the skill does not do what the user asks.",
),
],
)
result = engine.call(decision)
log.append(
decision,
result,
extra={
"phase": "navigate:intent",
"run_id": request.id,
"skill": f"{skill.category}.{skill.name}",
},
)
fits = result.prob("same") >= tau
trace.append(
"intent_guard",
request.id,
category=skill.category,
skill=skill.name,
selected=result.selected,
probs=result.probs,
fits=fits,
)
return fits
def tree_summary(tree: dict[str, list[Skill]]) -> str:
lines = []
for category in sorted(tree):