authoring UX: sequential elicitation questions + optional creation approval

Elicitation now asks one question at a time: only one PendingQuestion is
live, and the next is posted only after the current is answered (an empty
answer is accepted) or skipped. Each question gets a fresh
codegen.elicitation.answer_timeout (default 30s) that resets on every answer
submit; a timeout stops the sequence. questions_timeout is now traced only on
a real timeout. Front ends need no change — they read pending_questions().

Add opt-in creation_approval: the single-slot llm draft worker blocks after
authoring a proposal and before anything is registered; approve/deny via the
REPL, dashboard (/api/approvals + UI), or a gateway chat reply (yes/no). One
prompt per creation request (a category approval covers its chained skill);
denial or timeout aborts creation. Off by default.

Tests updated for both; full stdlib suite passes (337).
This commit is contained in:
gabby committed 2026-10-01 23:57:03 +00:00
1 parent 25ade160df
commit 215c22afb8
10 files changed
+684 -67

No files matched your search

+43
View File
@@ -34,6 +34,17 @@ _REPAIR_ACTIONS = {
"no_repair": "no_repair",
}
_APPROVAL_ACTIONS = {
"yes": True,
"y": True,
"approve": True,
"ok": True,
"no": False,
"n": False,
"deny": False,
"skip": False,
}
def _strip_run_id(text: str) -> str:
return _LEADING_RUN_ID.sub("", text or "")
@@ -65,6 +76,7 @@ class GatewayService:
self._pending_owner: str | None = None
self._question_for_chat: dict[str, str] = {}
self._repair_for_chat: dict[str, str] = {}
self._approval_for_chat: dict[str, str] = {}
self._surfaced: set[str] = set()
self._route_lock = threading.Lock()
self._stop = threading.Event()
@@ -131,6 +143,12 @@ class GatewayService:
status, detail = self.scheduler.resolve_repair(offer_id, action)
self._surfaced.add(offer_id)
self._reply(reply_to, detail)
elif msg.chat_id in self._approval_for_chat and msg.text.strip().lower() in _APPROVAL_ACTIONS:
approval_id = self._approval_for_chat.pop(msg.chat_id)
approved = _APPROVAL_ACTIONS[msg.text.strip().lower()]
status, detail = self.scheduler.answer_approval(approval_id, approved)
self._surfaced.add(approval_id)
self._reply(reply_to, detail)
else:
status, detail, run_id = self.scheduler.submit_request(
msg.text, source=self.source_for(msg.chat_id)
@@ -199,6 +217,31 @@ class GatewayService:
),
)
approvals = self.scheduler.pending_approvals()
live_ids = {a["id"] for a in approvals}
self._approval_for_chat = {
chat: aid for chat, aid in self._approval_for_chat.items() if aid in live_ids
}
for item in approvals:
if item["id"] in self._surfaced:
continue
self._surfaced.add(item["id"])
chat = self._owner_of(item["run_id"]) or origin or self.home_channel
if chat:
self._approval_for_chat[chat] = item["id"]
target = (
item["category"]
if item["kind"] == "category"
else f"{item['category']}.{item['skill']}"
)
self._reply(
chat,
(
f"Approve creating new {item['kind']} {target}: "
f"{item['description']}\nReply yes / no."
),
)
# ---- scheduler requeue hook (called under the scheduler lock) ----
def on_request_requeued(self, parent_id: str, child_id: str) -> None: