assessment: make assess/fidelity SemIf decisions, drop LLM from decision path
Assessment was an LLM generation step emitting prose. Move it to SemIf: - assess:outcome (success/failure @ tau) and assess:requeue (complete/retry, updated_request = request.text bounded by max_reentries) are logged decisions. - Run summary is deterministic (category.skill + ok/failed + action_log/new_state). - Fidelity gate is a real authoring:fidelity accept/reconsider decision plus static integration findings; it only triggers a rewrite, never a diagnosis. - Corrective regens receive the raw evidence bundle as-is (render_evidence), never an LLM paraphrase. - Every EngineUnavailable is fatal app-wide: Scheduler.fatal is recorded, the worker stops, and the CLI prints 'decision engine not available' and exits non-zero. Remove llm.assess/review_skill_body (keep _parse_json). - Tests: ScriptedEngine double in tests/conftest.py for scheduling mechanics; replace the review_skill_body integration test with a SemIf fidelity test; add deterministic-summary and evidence-renderer unit tests.
This commit is contained in:
1 parent
ddc5cb66c8
commit
3d0cff325c
16 files changed
+610
-463
No files matched your search
+16
-10
@@ -2,24 +2,25 @@
|
||||
|
||||
A skill can pause its run by returning ActionResult(..., needs_input="<q>");
|
||||
the scheduler keeps the run pending, and `answer` resumes it by re-invoking
|
||||
only `act` with the human's answer on request.user_input. No mocking: the
|
||||
scheduler uses the lazy engine (never loaded) and a real-but-unreachable LLM
|
||||
endpoint, so assessments degrade to failure — which is fine for these tests.
|
||||
only `act` with the human's answer on request.user_input. Assessment is now a
|
||||
SemIf decision, so these mechanics tests drive the loop with a deterministic
|
||||
scripted engine (see conftest) rather than loading the real GGUF.
|
||||
"""
|
||||
|
||||
from semif_agent.decisions import DecisionRequest, DecisionResult, Option, Request
|
||||
from semif_agent.engine import EngineConfig, SemIfEngine
|
||||
from semif_agent.llm import LLMClient
|
||||
from semif_agent.log import DecisionLog
|
||||
from semif_agent.scheduler import Scheduler
|
||||
from semif_agent.skills import ActionResult, Prediction, Skill
|
||||
from semif_agent.trace import TraceLog
|
||||
|
||||
from tests.conftest import ScriptedEngine
|
||||
|
||||
def build_scheduler(tmp_path):
|
||||
|
||||
def build_scheduler(tmp_path, choices=None):
|
||||
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
|
||||
trace = TraceLog(str(tmp_path / "runs.jsonl"))
|
||||
engine = SemIfEngine(EngineConfig())
|
||||
engine = ScriptedEngine(choices=choices, default="success")
|
||||
llm = LLMClient(base_url="http://localhost:1/v1", model="test")
|
||||
return Scheduler(
|
||||
engine=engine,
|
||||
@@ -109,16 +110,21 @@ def test_predict_decisions_logged_on_completion(tmp_path):
|
||||
)
|
||||
|
||||
skill = Skill(name="t.x", category="t", description="", predict=predict, act=act)
|
||||
scheduler = build_scheduler(tmp_path)
|
||||
scheduler = build_scheduler(
|
||||
tmp_path,
|
||||
choices={"achieve the user's goal": "failure", "complete, or should it run again": "complete"},
|
||||
)
|
||||
|
||||
scheduler._run_skill(skill, Request("x"))
|
||||
assert scheduler.log.read() == []
|
||||
|
||||
scheduler.answer("yes")
|
||||
rows = scheduler.log.read()
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["extra"]["phase"] == "predict"
|
||||
assert rows[0]["extra"]["run_ok"] is False
|
||||
predict_rows = [r for r in rows if r.get("extra", {}).get("phase") == "predict"]
|
||||
assert len(predict_rows) == 1
|
||||
assert predict_rows[0]["extra"]["run_ok"] is False
|
||||
phases = [r.get("extra", {}).get("phase") for r in rows]
|
||||
assert "assess:outcome" in phases and "assess:requeue" in phases
|
||||
|
||||
|
||||
def test_busy_abandons_pending(tmp_path):
|
||||
|
||||
Reference in new issue
Block a user