Files
semif-agent/tests/test_contract.py
T
Denton Social 22f91e0360 response: rebuild as a closed tree of canned replies; drop the gate
There is no up-front handle/ignore filter any more. Every input is scored
and dispatched; inputs that are not tasks fall through navigation into the
closed response category of hardcoded canned lines (greeting/thanks/
acknowledge/farewell/affirm/unable + the catchall response.clarify). The
category is CANNED_CATEGORIES: navigation offers no create_skill there,
dispatch/restart refuse to author it, and the runner skips assessment and
repair for it (a canned line has no side effect to assess).

Removes _contains_request/build_gate_decision and the dropped path.
2026-09-29 03:46:53 -05:00

46 lines
1.4 KiB
Python

from semif_agent.decisions import DecisionRequest, DecisionResult, Option, Request
def test_to_semif_row_shape():
request = DecisionRequest(
state="some state",
question="some question?",
options=[Option("a", "A."), Option("b", "B.")],
id="abc",
)
row = request.to_semif_row()
assert row["id"] == "abc"
assert row["state"] == "some state"
assert row["question"] == "some question?"
assert row["options"] == [
{"id": "a", "description": "A."},
{"id": "b", "description": "B."},
]
def test_result_selected_and_probs():
request = DecisionRequest(
state="s",
question="q",
options=[Option("a", "A."), Option("b", "B.")],
)
result = DecisionResult(
request=request, option_ids=["a", "b"], probabilities=[0.3, 0.7]
)
assert result.selected == "b"
assert result.probs == {"a": 0.3, "b": 0.7}
assert result.prob("a") == 0.3
def test_request_requeue_preserves_state():
original = Request(text="t", priority=0.7)
original.resume["from_skill"] = "response.clarify"
updated = original.copy_for_requeue()
assert updated.id == original.id
assert updated.priority == original.priority
assert updated.resume["from_skill"] == "response.clarify"
assert updated.reentries == original.reentries + 1
def test_request_user_input_defaults_none():
assert Request(text="t").user_input is None