gate: stop dropping lookups by carrying expectation + skills in the state

The binary gate asked "Does this input contain an actionable request?" over
the raw text alone, so the model read information requests as small talk:
"tell me the next event in my nextcloud calendar" scored 0.599 (under tau
0.6) and "what is the next event...?" scored 0.191, both dropped. The state
now states that the user expects handling, that looking values up in a
configured service is a real task, and lists the available skills; the
question/options say handle/ignore. On the real model every lookup variant
scores 0.9998+ while chatter stays at 0.016-0.125, and the new jarvis
integration battery pins both sides.
This commit is contained in:
Denton Social committed 2026-09-26 06:04:39 -05:00
1 parent b66d1e325a
commit de2c1a73f2
5 files changed
+115 -8

No files matched your search

+3 -1
View File
@@ -52,7 +52,9 @@ supplied options; an LLM is used only for generation and self-assessment.
``` ```
cli.py argparse: run (REPL / --script), dream, skills, status, relabel, cli.py argparse: run (REPL / --script), dream, skills, status, relabel,
dashboard dashboard
scheduler.py gate -> choice(tau) -> score -> queue; preempt + requeue; scheduler.py gate (handle/ignore; state carries the user's expectation +
the available skills, so lookups are not read as small talk)
-> choice(tau) -> score -> queue; preempt + requeue;
a skill run paused for input (needs_input) keeps `current` a skill run paused for input (needs_input) keeps `current`
busy; `answer` routes straight to the pending run, bypassing busy; `answer` routes straight to the pending run, bypassing
gate/score/navigation; skill-body authoring is an ASYNC single-slot gate/score/navigation; skill-body authoring is an ASYNC single-slot
+2 -1
View File
@@ -13,7 +13,8 @@ A local desktop CLI agent whose control flow is a single decision model (SemIf).
``` ```
intake (typed / events / timers / other skills) intake (typed / events / timers / other skills)
└─ contains_request? (gate: is this even actionable?) └─ contains_request? (gate: should the agent handle this? the state
carries the user's expectation + available skills)
└─ choice (SemIf: "should this interrupt the current process?") └─ choice (SemIf: "should this interrupt the current process?")
├─ yes → preempt current, requeue it with state preserved ├─ yes → preempt current, requeue it with state preserved
└─ no → score (SemIf: "how urgent?") └─ no → score (SemIf: "how urgent?")
+40 -5
View File
@@ -53,10 +53,12 @@ from .skills import (
merge_seed_store, merge_seed_store,
merge_skill_store, merge_skill_store,
navigate, navigate,
tree_summary,
) )
from .trace import TraceLog from .trace import TraceLog
GATE_YES = "yes" GATE_YES = "yes"
GATE_CAPABILITY_CHARS = 1200
CHOICE_INTERRUPT = "interrupt" CHOICE_INTERRUPT = "interrupt"
URGENCY_OPTIONS = [ URGENCY_OPTIONS = [
("critical", "Immediate danger or critical failure."), ("critical", "Immediate danger or critical failure."),
@@ -67,6 +69,43 @@ URGENCY_OPTIONS = [
URGENCY_WEIGHTS = {"critical": 1.0, "high": 0.75, "medium": 0.5, "low": 0.25} URGENCY_WEIGHTS = {"critical": 1.0, "high": 0.75, "medium": 0.5, "low": 0.25}
def build_gate_decision(request: Request, tree: dict[str, list[Skill]]) -> DecisionRequest:
"""The top-level handle/ignore filter, with end-user expectation and the
agent's real capabilities in the state.
Without them the decision model reads an information request ("tell me the
next event in my nextcloud calendar") as small talk and drops it: "actionable"
implies a side effect, and the model cannot see that looking a value up in a
configured service is exactly what this agent does. The available skills are
listed so a request naming one of them is visibly within the agent's remit.
"""
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"
f"[Available skills:\n{capabilities}]"
)
return DecisionRequest(
state=state,
question="Should the agent handle this input?",
options=[
Option(
GATE_YES,
"Yes — do what it asks, including looking something up or "
"reporting information using the agent's skills.",
),
Option(
"no",
"No — it is not a request for the agent to do or answer anything "
"(background text, noise, or a bare greeting).",
),
],
)
@dataclass @dataclass
class Process: class Process:
request: Request request: Request
@@ -232,11 +271,7 @@ class Scheduler:
# ---- decision templates (all real SemIf, all logged) ---- # ---- decision templates (all real SemIf, all logged) ----
def _contains_request(self, request: Request) -> bool: def _contains_request(self, request: Request) -> bool:
decision = DecisionRequest( decision = build_gate_decision(request, self.tree)
state=compose_state(request),
question="Does this input contain an actionable request?",
options=[Option(GATE_YES, "Yes, it is actionable."), Option("no", "No, it is not.")],
)
result = self.engine.call(decision) result = self.engine.call(decision)
self.log.append( self.log.append(
decision, result, extra={"phase": "gate", "run_id": request.id} decision, result, extra={"phase": "gate", "run_id": request.id}
+36
View File
@@ -125,6 +125,42 @@ def test_pipeline_end_to_end(tmp_path):
assert "queue:" in skills assert "queue:" in skills
def test_gate_accepts_information_requests_and_rejects_noise(tmp_path):
"""Regression: the gate must not drop lookups phrased as questions.
Before the gate state carried the end-user expectation and the available
skills, "tell me the next event in my nextcloud calendar" scored 0.599
(just under tau 0.6) and "what is the next event in my nextcloud calendar?"
scored 0.191, so both were dropped as "no actionable request". All lookup
variants must pass now, while chatter stays out.
"""
config = load_config()
require_real(config)
config["log"] = str(tmp_path / "decisions.jsonl")
config["trace"] = str(tmp_path / "runs.jsonl")
scheduler, config = build_scheduler(config)
lookups = [
"tell me the next event in my nextcloud calendar",
"what is the next event in my nextcloud calendar?",
"what is the next event in my nextcloud calendar Morgan",
"tell me the next event in my nextcloud calendar Morgan",
"tell me the next even in my calendar",
"tell me the next event in my personal calendar",
]
noise = ["hello there", "thanks!", "the sky is blue", "what's up"]
for text in lookups:
accepted = scheduler._contains_request(Request(text))
row = scheduler.log.read()[-1]
print(f"[lookup] {row['predicted_probs']} accepted={accepted} {text!r}")
assert accepted, f"gate dropped a lookup: {text!r}"
for text in noise:
accepted = scheduler._contains_request(Request(text))
row = scheduler.log.read()[-1]
print(f"[noise] {row['predicted_probs']} accepted={accepted} {text!r}")
assert not accepted, f"gate accepted noise: {text!r}"
def test_busy_choice_path(tmp_path): def test_busy_choice_path(tmp_path):
config = load_config() config = load_config()
require_real(config) require_real(config)
+34 -1
View File
@@ -21,7 +21,13 @@ from semif_agent.decisions import Request
from semif_agent.engine import EngineConfig, EngineUnavailable, SemIfEngine from semif_agent.engine import EngineConfig, EngineUnavailable, SemIfEngine
from semif_agent.llm import LLMClient from semif_agent.llm import LLMClient
from semif_agent.log import DecisionLog from semif_agent.log import DecisionLog
from semif_agent.scheduler import PendingQuestion, RepairOffer, Scheduler, SkillWrite from semif_agent.scheduler import (
PendingQuestion,
RepairOffer,
Scheduler,
SkillWrite,
build_gate_decision,
)
from semif_agent.skills import ( from semif_agent.skills import (
ActionResult, ActionResult,
CategoryDraft, CategoryDraft,
@@ -405,6 +411,33 @@ def test_navigate_empty_tree_short_circuits(tmp_path):
assert any(e["kind"] == "create_category" for e in trace.read()) assert any(e["kind"] == "create_category" for e in trace.read())
def test_gate_decision_carries_expectation_and_capabilities():
"""The gate must know the user expects handling and what the agent can
actually do; without that context, lookups are read as small talk and
dropped (the nextcloud calendar regression)."""
tree = build_tree(build_skills({"skills": {}}))
tree["calendar"] = [
Skill(name="next_event", category="calendar", description="Report the next event.")
]
decision = build_gate_decision(
Request("tell me the next event in my nextcloud calendar"), tree
)
assert "tell me the next event in my nextcloud calendar" in decision.state
assert "expects it to handle this input" in decision.state
assert "reading or looking up information" in decision.state
assert "calendar: next_event" in decision.state
assert decision.question == "Should the agent handle this input?"
assert [o.id for o in decision.options] == ["yes", "no"]
assert "looking something up" in decision.options[0].description
assert "greeting" in decision.options[1].description
def test_gate_decision_empty_tree_still_builds():
decision = build_gate_decision(Request("hello"), {})
assert "(none yet)" in decision.state
assert decision.options[0].id == "yes"
def test_dispatch_create_category_without_engine_returns_error(tmp_path): def test_dispatch_create_category_without_engine_returns_error(tmp_path):
"""An empty tree short-circuits to CreateCategory; without an engine the """An empty tree short-circuits to CreateCategory; without an engine the
category authoring fails gracefully instead of leaving the scheduler wedged.""" category authoring fails gracefully instead of leaving the scheduler wedged."""