scheduler/gateway: carry skill identity structurally, not in action_log
Skill bodies prefixed their own `category.name` into `ActionResult.action_log`, which duplicated the runner's deterministic summary prefix and leaked the name into the text the gateways speak. Identity is not data for the output string. - bodies (seeds, canned replies, housekeeping meta skills) write only the real result; the runner already owns the `category.name:` summary prefix - `run_queue`/`submit_request`/`answer` now return a structured `SchedulerReply` (status, text, run_id, skill_ref, result); the gateway reads `skill_ref` and `result` from it instead of regex-parsing them back out of the summary - drop the gateway's `_SKILL_REF`/`_LEADING_RUN_ID` parsing helpers - fix a latent double-prefix when a failed run had an empty action_log - CODEGEN.md: generated bodies must not prefix the skill name
This commit is contained in:
1 parent
d0c1dccffd
commit
e9a7fc73ee
22 files changed
+248
-200
No files matched your search
@@ -109,9 +109,9 @@ def test_pipeline_end_to_end(tmp_path):
|
||||
"what is the delivery status of my parcel",
|
||||
]
|
||||
for text in inputs:
|
||||
status, detail = scheduler.submit(text)
|
||||
print(f"[{status}] {detail}")
|
||||
assert status in ("running", "queued", "rejected")
|
||||
reply = scheduler.submit(text)
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert reply.status in ("running", "queued", "rejected")
|
||||
|
||||
scheduler.run_queue()
|
||||
|
||||
@@ -295,9 +295,9 @@ def test_busy_queue_path(tmp_path):
|
||||
_install_tracking_fixture(scheduler)
|
||||
|
||||
scheduler.busy("driving on the freeway", skill="driving")
|
||||
status, detail = scheduler.submit("tell me if my package was delivered")
|
||||
print(f"[{status}] {detail}")
|
||||
assert status == "queued"
|
||||
reply = scheduler.submit("tell me if my package was delivered")
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert reply.status == "queued"
|
||||
scheduler.idle()
|
||||
|
||||
|
||||
@@ -499,13 +499,13 @@ def test_create_skill_empty_category_does_not_wedge(tmp_path):
|
||||
scheduler.tree["travel_planning"] = []
|
||||
|
||||
for _ in range(2):
|
||||
status, detail = scheduler.submit("look up flights to japan for february")
|
||||
print(f"[{status}] {detail}")
|
||||
assert status in ("running", "queued", "rejected", "error")
|
||||
reply = scheduler.submit("look up flights to japan for february")
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert reply.status in ("running", "queued", "rejected", "error")
|
||||
assert scheduler.current is None, "scheduler must never stay wedged after a submit"
|
||||
|
||||
status, detail = scheduler.submit("tell me if my package was delivered")
|
||||
print(f"[{status}] {detail}")
|
||||
reply = scheduler.submit("tell me if my package was delivered")
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert scheduler.current is None
|
||||
|
||||
|
||||
@@ -533,10 +533,10 @@ def test_create_simplex_send_skill(tmp_path):
|
||||
f"the simplex seeds must be loaded, got {seeded}"
|
||||
)
|
||||
|
||||
status, detail = scheduler.submit("send a simplex message to pepper saying hi")
|
||||
print(f"[{status}] {detail}")
|
||||
assert status in ("running", "queued", "rejected")
|
||||
assert "new skill for simplex" in detail, (
|
||||
reply = scheduler.submit("send a simplex message to pepper saying hi")
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert reply.status in ("running", "queued", "rejected")
|
||||
assert "new skill for simplex" in reply.text, (
|
||||
"a send request must route to create_skill for simplex"
|
||||
)
|
||||
assert scheduler.current is None, "gate must be free again right after the draft is queued"
|
||||
@@ -627,9 +627,9 @@ def test_skill_pauses_for_input_and_resumes(tmp_path):
|
||||
assert scheduler.pending is not None
|
||||
assert scheduler.current is not None
|
||||
|
||||
status, detail = scheduler.answer("AB123")
|
||||
print(f"[{status}] {detail}")
|
||||
assert status == "ran"
|
||||
reply = scheduler.answer("AB123")
|
||||
print(f"[{reply.status}] {reply.text}")
|
||||
assert reply.status == "ran"
|
||||
assert seen == ["AB123"]
|
||||
assert scheduler.pending is None
|
||||
assert scheduler.current is None
|
||||
@@ -653,7 +653,7 @@ def test_empty_result_is_assessed_as_success(tmp_path):
|
||||
|
||||
def act(ctx, request):
|
||||
return ActionResult(
|
||||
action_log="simplex.next_message: no unread SimpleX messages.",
|
||||
action_log="no unread SimpleX messages.",
|
||||
new_state="no unread SimpleX messages",
|
||||
)
|
||||
|
||||
|
||||
+12
-11
@@ -176,7 +176,10 @@ def test_gateway_skill_config_disables_humanize():
|
||||
service = build_service_with_store(
|
||||
llm, {"humanize": {"enabled": True}, "simplex": {}}, store
|
||||
)
|
||||
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
|
||||
service._reply(
|
||||
"simplex", "c", "time.now: ok — 12:00", kind="result",
|
||||
skill_ref="time.now", result="12:00",
|
||||
)
|
||||
assert service.outbound["simplex"].get_nowait().text == "time.now: ok — 12:00"
|
||||
assert llm.calls == []
|
||||
|
||||
@@ -190,7 +193,10 @@ def test_gateway_skill_config_enables_humanize_over_platform():
|
||||
{"humanize": {"enabled": False}, "simplex": {"humanize": False}},
|
||||
store,
|
||||
)
|
||||
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
|
||||
service._reply(
|
||||
"simplex", "c", "time.now: ok — 12:00", kind="result",
|
||||
skill_ref="time.now", result="12:00",
|
||||
)
|
||||
assert service.outbound["simplex"].get_nowait().text == "It is 12:00."
|
||||
|
||||
|
||||
@@ -201,13 +207,8 @@ def test_gateway_skill_config_absent_falls_back_to_platform():
|
||||
service = build_service_with_store(
|
||||
llm, {"humanize": {"enabled": True}, "simplex": {}}, store
|
||||
)
|
||||
service._reply("simplex", "c", "time.now: ok — 12:00", kind="result")
|
||||
service._reply(
|
||||
"simplex", "c", "time.now: ok — 12:00", kind="result",
|
||||
skill_ref="time.now", result="12:00",
|
||||
)
|
||||
assert service.outbound["simplex"].get_nowait().text == "It is 12:00."
|
||||
|
||||
|
||||
def test_skill_ref_parses_summary_and_resumed_marker():
|
||||
from semif_agent.gateway.service import _skill_ref
|
||||
|
||||
assert _skill_ref("time.now: ok — 12:00") == "time.now"
|
||||
assert _skill_ref("[resumed] track.manual: ok — sent") == "track.manual"
|
||||
assert _skill_ref("queued") is None
|
||||
+11
-11
@@ -67,8 +67,8 @@ def test_skill_pause_and_answer(tmp_path):
|
||||
assert scheduler.current.skill == "track.manual"
|
||||
assert scheduler.log.read() == [], "sub-decisions must be deferred until completion"
|
||||
|
||||
status, detail = scheduler.answer("AB123")
|
||||
assert status == "ran"
|
||||
reply = scheduler.answer("AB123")
|
||||
assert reply.status == "ran"
|
||||
assert seen == ["AB123"]
|
||||
assert scheduler.pending is None
|
||||
assert scheduler.current is None
|
||||
@@ -82,9 +82,9 @@ def test_skill_pause_and_answer(tmp_path):
|
||||
|
||||
def test_answer_without_pending_is_error(tmp_path):
|
||||
scheduler = build_scheduler(tmp_path)
|
||||
status, detail = scheduler.answer("hello")
|
||||
assert status == "error"
|
||||
assert "waiting for input" in detail
|
||||
reply = scheduler.answer("hello")
|
||||
assert reply.status == "error"
|
||||
assert "waiting for input" in reply.text
|
||||
|
||||
|
||||
def test_act_decisions_logged_on_completion(tmp_path):
|
||||
@@ -164,13 +164,13 @@ def test_resume_can_ask_again(tmp_path):
|
||||
scheduler = build_scheduler(tmp_path)
|
||||
|
||||
scheduler._run_skill(skill, Request("track"))
|
||||
status, detail = scheduler.answer("XYZ")
|
||||
assert status == "needs_input"
|
||||
reply = scheduler.answer("XYZ")
|
||||
assert reply.status == "needs_input"
|
||||
assert seen == ["XYZ"]
|
||||
assert scheduler.pending is not None
|
||||
|
||||
status, detail = scheduler.answer("AB123")
|
||||
assert status == "ran"
|
||||
reply = scheduler.answer("AB123")
|
||||
assert reply.status == "ran"
|
||||
assert scheduler.pending is None
|
||||
assert scheduler.current is None
|
||||
|
||||
@@ -196,8 +196,8 @@ def test_empty_answer_is_accepted_and_forwarded(tmp_path):
|
||||
result = scheduler._run_skill(skill, Request("track my package"))
|
||||
assert result.kind == "needs_input"
|
||||
|
||||
status, detail = scheduler.answer("")
|
||||
assert status == "ran", detail
|
||||
reply = scheduler.answer("")
|
||||
assert reply.status == "ran", reply.text
|
||||
assert seen == [None, ""], "the empty answer must reach act"
|
||||
assert scheduler.pending is None
|
||||
assert scheduler.current is None
|
||||
|
||||
+10
-10
@@ -1591,15 +1591,15 @@ def test_skill_pre_act_contract_pause_and_resume(tmp_path):
|
||||
assert scheduler.pending is not None
|
||||
assert scheduler.pending.pre_act is True
|
||||
|
||||
status, detail = scheduler.answer("AB123")
|
||||
assert status == "needs_input"
|
||||
reply = scheduler.answer("AB123")
|
||||
assert reply.status == "needs_input"
|
||||
assert scheduler.pending is not None
|
||||
assert scheduler.pending.pre_act is False
|
||||
assert scheduler.pending.request.meta["config_answers"]["token"] == "AB123"
|
||||
assert "Confirm?" in scheduler.pending.question
|
||||
|
||||
status, detail = scheduler.answer("yes")
|
||||
assert status == "ran"
|
||||
reply = scheduler.answer("yes")
|
||||
assert reply.status == "ran"
|
||||
assert scheduler.pending is None
|
||||
|
||||
|
||||
@@ -1631,8 +1631,8 @@ def test_pre_act_skip_leaves_variable_unset_and_does_not_reask(tmp_path):
|
||||
assert result.kind == "needs_input"
|
||||
assert scheduler.pending is not None and scheduler.pending.pre_act is True
|
||||
|
||||
status, detail = scheduler.answer("")
|
||||
assert status == "ran", detail
|
||||
reply = scheduler.answer("")
|
||||
assert reply.status == "ran", reply.text
|
||||
assert scheduler.pending is None
|
||||
assert "token" not in seen, "a skipped variable must stay unset"
|
||||
|
||||
@@ -1664,13 +1664,13 @@ def test_pre_act_skip_advances_to_next_missing_variable(tmp_path):
|
||||
assert result.kind == "needs_input"
|
||||
assert "`alpha`" in result.summary
|
||||
|
||||
status, detail = scheduler.answer("")
|
||||
assert status == "needs_input"
|
||||
reply = scheduler.answer("")
|
||||
assert reply.status == "needs_input"
|
||||
assert scheduler.pending is not None
|
||||
assert "`beta`" in scheduler.pending.question
|
||||
|
||||
status, detail = scheduler.answer("")
|
||||
assert status == "ran", detail
|
||||
reply = scheduler.answer("")
|
||||
assert reply.status == "ran", reply.text
|
||||
assert "alpha" not in seen and "beta" not in seen
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user