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

+36
View File
@@ -125,6 +125,42 @@ def test_pipeline_end_to_end(tmp_path):
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):
config = load_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.llm import LLMClient
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 (
ActionResult,
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())
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):
"""An empty tree short-circuits to CreateCategory; without an engine the
category authoring fails gracefully instead of leaving the scheduler wedged."""