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
@@ -506,7 +506,7 @@ def _build_ics(uid, summary, start, end, all_day, stamp, description=""):
|
||||
def _ask(request, field, question):
|
||||
request.meta["create_event_awaiting"] = field
|
||||
return ActionResult(
|
||||
action_log=f"calendar.create_event: waiting for {field}",
|
||||
action_log=f"waiting for {field}",
|
||||
new_state=request.text,
|
||||
needs_input=question,
|
||||
)
|
||||
@@ -526,7 +526,7 @@ def act(ctx, request):
|
||||
fields = _extract_fields(ctx, request)
|
||||
except BridgeError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"calendar.create_event: {exc}",
|
||||
action_log=str(exc),
|
||||
new_state=request.text,
|
||||
)
|
||||
request.meta["create_event_fields"] = fields
|
||||
@@ -576,12 +576,12 @@ def act(ctx, request):
|
||||
calendars = _discover_calendars(ctx)
|
||||
except CalDavError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"calendar.create_event: calendar discovery failed: {exc}",
|
||||
action_log=f"calendar discovery failed: {exc}",
|
||||
new_state=request.text,
|
||||
)
|
||||
if not calendars:
|
||||
return ActionResult(
|
||||
action_log="calendar.create_event: no calendars found on the account",
|
||||
action_log="no calendars found on the account",
|
||||
new_state=request.text,
|
||||
)
|
||||
|
||||
@@ -606,7 +606,7 @@ def act(ctx, request):
|
||||
except CalDavError as exc:
|
||||
return ActionResult(
|
||||
action_log=(
|
||||
f"calendar.create_event: could not create {title!r} on "
|
||||
f"could not create {title!r} on "
|
||||
f"{calendar!r}: {exc}"
|
||||
),
|
||||
new_state=request.text,
|
||||
@@ -622,7 +622,7 @@ def act(ctx, request):
|
||||
)
|
||||
report = f"Created {title!r} on calendar {calendar!r}: {when_text} (UID {uid})."
|
||||
return ActionResult(
|
||||
action_log=f"calendar.create_event: {report}",
|
||||
action_log=report,
|
||||
new_state=report,
|
||||
decisions=decisions,
|
||||
)
|
||||
@@ -422,7 +422,7 @@ def test_unreachable_server_fails_honestly():
|
||||
action, request, _engine = run(
|
||||
None, "http://127.0.0.1:1", "add standup on 2026-11-10 at 9am"
|
||||
)
|
||||
assert action.action_log.startswith("calendar.create_event:"), action.action_log
|
||||
assert action.action_log and "calendar.create_event" not in action.action_log, action.action_log
|
||||
assert action.new_state == request.text
|
||||
print(action.action_log)
|
||||
|
||||
|
||||
@@ -362,12 +362,12 @@ def act(ctx, request):
|
||||
calendars = _discover_calendars(ctx)
|
||||
except CalDavError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"calendar.next_event: calendar discovery failed: {exc}",
|
||||
action_log=f"calendar discovery failed: {exc}",
|
||||
new_state=request.text,
|
||||
)
|
||||
if not calendars:
|
||||
return ActionResult(
|
||||
action_log="calendar.next_event: calendar discovery failed: no calendars found",
|
||||
action_log="calendar discovery failed: no calendars found",
|
||||
new_state=request.text,
|
||||
)
|
||||
|
||||
@@ -375,7 +375,7 @@ def act(ctx, request):
|
||||
calendar = _resolve_calendar(ctx, request, calendars, decisions)
|
||||
if not calendar:
|
||||
return ActionResult(
|
||||
action_log="calendar.next_event aborted: no calendar resolved.",
|
||||
action_log="aborted: no calendar resolved.",
|
||||
new_state=request.text,
|
||||
decisions=decisions,
|
||||
)
|
||||
@@ -395,7 +395,7 @@ def act(ctx, request):
|
||||
events = _parse_events(_calendar_payloads(body), local_tz)
|
||||
except CalDavError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"calendar.next_event failed on {calendar!r}: {exc}",
|
||||
action_log=f"failed on {calendar!r}: {exc}",
|
||||
new_state=request.text,
|
||||
decisions=decisions,
|
||||
)
|
||||
|
||||
@@ -73,19 +73,17 @@ def act(ctx, request):
|
||||
try:
|
||||
payload = _get(ctx, "/health")
|
||||
except BridgeError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"simplex.connect_link: {exc}", new_state=request.text
|
||||
)
|
||||
return ActionResult(action_log=str(exc), new_state=request.text)
|
||||
if not payload.get("ok"):
|
||||
return ActionResult(
|
||||
action_log="simplex.connect_link: simplex forwarding bridge is not healthy",
|
||||
action_log="simplex forwarding bridge is not healthy",
|
||||
new_state=request.text,
|
||||
)
|
||||
try:
|
||||
payload = _get(ctx, "/address")
|
||||
except BridgeError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"simplex.connect_link failed: {exc}",
|
||||
action_log=f"reading the contact link failed: {exc}",
|
||||
new_state=request.text,
|
||||
)
|
||||
short = str(payload.get("short_link") or "").strip()
|
||||
@@ -93,7 +91,7 @@ def act(ctx, request):
|
||||
if not (short or full):
|
||||
return ActionResult(
|
||||
action_log=(
|
||||
"simplex.connect_link: the bridge returned no SimpleX "
|
||||
"the bridge returned no SimpleX "
|
||||
"contact link; the bot has no address yet."
|
||||
),
|
||||
new_state=request.text,
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_unreachable_bridge_fails_honestly():
|
||||
ctx = ActionContext(engine=None, config=config("http://127.0.0.1:1"))
|
||||
request = Request("give me your simplex link")
|
||||
action = skill.act(ctx, request)
|
||||
assert action.action_log.startswith("simplex.connect_link:"), action.action_log
|
||||
assert action.action_log and "simplex.connect_link" not in action.action_log, action.action_log
|
||||
assert action.new_state == request.text
|
||||
print(action.action_log)
|
||||
|
||||
|
||||
@@ -140,11 +140,11 @@ def act(ctx, request):
|
||||
try:
|
||||
payload = _get(ctx, "/inbox")
|
||||
except BridgeError as exc:
|
||||
return ActionResult(action_log=f"simplex.next_message: {exc}", new_state=request.text)
|
||||
return ActionResult(action_log=str(exc), new_state=request.text)
|
||||
senders = _senders(payload.get("messages") or [])
|
||||
if not senders:
|
||||
return ActionResult(
|
||||
action_log="simplex.next_message: no unread SimpleX messages.",
|
||||
action_log="no unread SimpleX messages.",
|
||||
new_state="no unread SimpleX messages",
|
||||
)
|
||||
decisions = []
|
||||
@@ -155,14 +155,14 @@ def act(ctx, request):
|
||||
)
|
||||
except BridgeError as exc:
|
||||
return ActionResult(
|
||||
action_log=f"simplex.next_message failed reading {contact!r}: {exc}",
|
||||
action_log=f"failed reading {contact!r}: {exc}",
|
||||
new_state=request.text,
|
||||
decisions=decisions,
|
||||
)
|
||||
message = payload.get("message")
|
||||
if not message:
|
||||
return ActionResult(
|
||||
action_log=f"simplex.next_message: no unread message from {contact!r}.",
|
||||
action_log=f"no unread message from {contact!r}.",
|
||||
new_state="no unread SimpleX messages",
|
||||
decisions=decisions,
|
||||
)
|
||||
|
||||
@@ -237,7 +237,7 @@ def test_unreachable_bridge_fails_honestly():
|
||||
ctx = ActionContext(engine=engine, config=config("http://127.0.0.1:1"))
|
||||
request = Request("read my next simplex message")
|
||||
action = skill.act(ctx, request)
|
||||
assert action.action_log.startswith("simplex.next_message:"), action.action_log
|
||||
assert action.action_log and "simplex.next_message" not in action.action_log, action.action_log
|
||||
assert action.new_state == request.text, "a failed read must not fake a result"
|
||||
print(action.action_log)
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@ CONTRACT = {}
|
||||
def act(ctx, request):
|
||||
today = local_now(ctx.config).date()
|
||||
message = f"Today is {today.strftime('%A, %B %d, %Y')} ({today.isoformat()})."
|
||||
return ActionResult(action_log=f"time.date: {message}", new_state=message)
|
||||
return ActionResult(action_log=message, new_state=message)
|
||||
@@ -33,4 +33,4 @@ def act(ctx, request):
|
||||
f"It is {now.strftime('%H:%M')} "
|
||||
f"({now.strftime('%I:%M %p').lstrip('0')} {zone}{_offset_text(now)})."
|
||||
)
|
||||
return ActionResult(action_log=f"time.now: {message}", new_state=message)
|
||||
return ActionResult(action_log=message, new_state=message)
|
||||
@@ -71,17 +71,17 @@ def act(ctx, request):
|
||||
if when is None:
|
||||
request.meta["alarm_awaiting"] = True
|
||||
return ActionResult(
|
||||
action_log="time.set_alarm: waiting for a time",
|
||||
action_log="waiting for a time",
|
||||
new_state=request.text,
|
||||
needs_input="What time should the alarm go off? (e.g. '5pm')",
|
||||
)
|
||||
if ctx.timers is None:
|
||||
return ActionResult(
|
||||
action_log="time.set_alarm: no timer service is available in this front end",
|
||||
action_log="no timer service is available in this front end",
|
||||
new_state=request.text,
|
||||
)
|
||||
|
||||
label = when.strftime("%H:%M")
|
||||
ctx.timers.set_alarm(when, label, run_id=request.id, source=request.source)
|
||||
message = f"Alarm set for {when.strftime('%H:%M')} on {when.strftime('%A')}."
|
||||
return ActionResult(action_log=f"time.set_alarm: {message}", new_state=message)
|
||||
return ActionResult(action_log=message, new_state=message)
|
||||
@@ -111,13 +111,13 @@ def act(ctx, request):
|
||||
if seconds is None:
|
||||
request.meta["timer_awaiting"] = True
|
||||
return ActionResult(
|
||||
action_log="time.set_timer: waiting for a duration",
|
||||
action_log="waiting for a duration",
|
||||
new_state=request.text,
|
||||
needs_input="How long should the timer run? (e.g. '5 minutes')",
|
||||
)
|
||||
if ctx.timers is None:
|
||||
return ActionResult(
|
||||
action_log="time.set_timer: no timer service is available in this front end",
|
||||
action_log="no timer service is available in this front end",
|
||||
new_state=request.text,
|
||||
)
|
||||
|
||||
@@ -125,4 +125,4 @@ def act(ctx, request):
|
||||
timer = ctx.timers.set_timer(seconds, label, run_id=request.id, source=request.source)
|
||||
due = timer.due_datetime().strftime("%H:%M")
|
||||
message = f"Timer set for {label}; it will fire at {due}."
|
||||
return ActionResult(action_log=f"time.set_timer: {message}", new_state=message)
|
||||
return ActionResult(action_log=message, new_state=message)
|
||||
Reference in new issue
Block a user