assess empty query results as success, not failure
A query skill whose correct answer is "nothing" (no unread SimpleX messages, no upcoming events) was marked failed by assess:outcome: the option text framed the decision as literal goal-achievement, so the model read "no messages" as the goal not being met. The run then offered a repair and could rewrite a working skill. Reword the assess:outcome options so a definitive "nothing found / nothing to do" result counts as success and only an error, refusal, or unresolved action is failure. Option ids and the question are unchanged, so the decision-log schema, dream labels, and existing unit tests are unaffected. Real-engine scores: empty inbox 0.145 -> 0.969, no events 0.132 -> 0.959, while unreachable/HTTP-401/discovery failures stay failure. Add an integration regression test and a CODEGEN.md note that an explicit empty/none result is a successful run.
This commit is contained in:
1 parent
7ee200d921
commit
ddbe5f167d
3 files changed
+58
-4
No files matched your search
+5
-1
@@ -422,7 +422,11 @@ Rules:
|
|||||||
action skill reports the service's real response. A generic "done" that omits
|
action skill reports the service's real response. A generic "done" that omits
|
||||||
the result is a broken output.
|
the result is a broken output.
|
||||||
- **Never an empty or placeholder output.** If there is genuinely nothing (empty
|
- **Never an empty or placeholder output.** If there is genuinely nothing (empty
|
||||||
inbox, no matching event), say so explicitly — that is a real result.
|
inbox, no matching event), say so explicitly — that is a real result, and a
|
||||||
|
**successful** run: the `assess:outcome` step treats a definitive "nothing
|
||||||
|
found / nothing to do" result as success. Phrase it as the answer the user
|
||||||
|
asked for ("checked the inbox: no unread messages"), not as an absence or an
|
||||||
|
error, so the assessment does not read a healthy empty result as a failure.
|
||||||
- **Never claim success you did not observe.** If the action failed, put the
|
- **Never claim success you did not observe.** If the action failed, put the
|
||||||
real failure in `action_log` and set `new_state` back to `request.text` (see
|
real failure in `action_log` and set `new_state` back to `request.text` (see
|
||||||
the hard requirements).
|
the hard requirements).
|
||||||
|
|||||||
+12
-2
@@ -310,8 +310,18 @@ class SkillRunner:
|
|||||||
),
|
),
|
||||||
question="Did the skill achieve the user's goal?",
|
question="Did the skill achieve the user's goal?",
|
||||||
options=[
|
options=[
|
||||||
Option("success", "Yes — the goal was met."),
|
Option(
|
||||||
Option("failure", "No — the goal was not met."),
|
"success",
|
||||||
|
"Yes — the skill carried out the request and produced a "
|
||||||
|
"truthful result. A definitive 'nothing found' or 'nothing "
|
||||||
|
"to do' result (empty inbox, no unread messages, no "
|
||||||
|
"matching event) counts as success.",
|
||||||
|
),
|
||||||
|
Option(
|
||||||
|
"failure",
|
||||||
|
"No — the request was not carried out, or the result is an "
|
||||||
|
"error, a refusal, or an unresolved action.",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
result = self.ctx.engine.call(outcome)
|
result = self.ctx.engine.call(outcome)
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ from semif_agent.codegen import (
|
|||||||
)
|
)
|
||||||
from semif_agent.decisions import Request
|
from semif_agent.decisions import Request
|
||||||
from semif_agent.dream import dream
|
from semif_agent.dream import dream
|
||||||
from semif_agent.engine import EngineUnavailable
|
from semif_agent.engine import EngineUnavailable, SemIfEngine
|
||||||
|
from semif_agent.log import DecisionLog
|
||||||
from semif_agent.scheduler import SkillWrite
|
from semif_agent.scheduler import SkillWrite
|
||||||
|
from semif_agent.skill import SkillRunner
|
||||||
from semif_agent.skills import (
|
from semif_agent.skills import (
|
||||||
ActionResult,
|
ActionResult,
|
||||||
|
ActionContext,
|
||||||
CategoryDraft,
|
CategoryDraft,
|
||||||
CreateCategory,
|
CreateCategory,
|
||||||
Skill,
|
Skill,
|
||||||
@@ -635,3 +638,40 @@ def test_skill_pauses_for_input_and_resumes(tmp_path):
|
|||||||
rows = scheduler.trace.read()
|
rows = scheduler.trace.read()
|
||||||
kinds = [e["kind"] for e in rows]
|
kinds = [e["kind"] for e in rows]
|
||||||
assert "needs_input" in kinds and "answered" in kinds and "assessed" in kinds
|
assert "needs_input" in kinds and "answered" in kinds and "assessed" in kinds
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_result_is_assessed_as_success(tmp_path):
|
||||||
|
"""A query skill whose correct answer is "nothing" is a successful run.
|
||||||
|
|
||||||
|
The `assess:outcome` options must treat a definitive empty/none result
|
||||||
|
(empty inbox, no matching event) as success; otherwise a healthy read is
|
||||||
|
marked failed and the repair loop offers to rewrite a working skill. This
|
||||||
|
exercises the real engine, since only it produces the probabilities.
|
||||||
|
"""
|
||||||
|
config = load_config()
|
||||||
|
require_real(config)
|
||||||
|
engine = SemIfEngine(build_engine_config(config))
|
||||||
|
|
||||||
|
def act(ctx, request):
|
||||||
|
return ActionResult(
|
||||||
|
action_log="simplex.next_message: no unread SimpleX messages.",
|
||||||
|
new_state="no unread SimpleX messages",
|
||||||
|
)
|
||||||
|
|
||||||
|
skill = Skill(
|
||||||
|
name="next_message",
|
||||||
|
category="simplex",
|
||||||
|
description="Read the next unread SimpleX message.",
|
||||||
|
act=act,
|
||||||
|
)
|
||||||
|
log = DecisionLog(str(tmp_path / "decisions.jsonl"))
|
||||||
|
runner = SkillRunner(ActionContext(engine=engine, config={}), log)
|
||||||
|
outcome = runner.run(skill, Request("What's my next simplex message?"))
|
||||||
|
print(f"[{outcome.success}] {outcome.summary}")
|
||||||
|
|
||||||
|
assert outcome.success is True, outcome.summary
|
||||||
|
phases = [row["extra"]["phase"] for row in log.read()]
|
||||||
|
assert "assess:outcome" in phases
|
||||||
|
assert "assess:requeue" not in phases, (
|
||||||
|
"an empty discovery must not be retried or repaired"
|
||||||
|
)
|
||||||
Reference in new issue
Block a user