feat(tasks): phase 5 — ask_operator (structured question, pause, resume)
The last backend piece: when the agent hits a decision only the operator can
make, it surfaces a structured question instead of guessing or stalling.
- ask_operator(prompt, why?, options?, context_entities?): nomos-local tool
that records a session_questions row, moves the task to awaiting_input, emits
question.raised, and ENDS the turn (the agent loop returns after it, so the
agent can't barrel past its own question). The prompt becomes the assistant's
visible message so the question also shows inline in the transcript.
- Two resume paths, both close the question + emit question.answered + return
the task to executing:
- Panel: POST /sessions/{id}/questions/{qid}/answer → resumes the agent in the
background with the answer injected (reusing the continuation machinery,
refactored continueSession → resumeSession). Returns 202; the reply lands via
message polling.
- Chat reply: the next chat message on a task with an open question IS the
answer — auto-closed in handleChat; the turn itself is the resume.
Verified end-to-end: forcing a decision paused the task at awaiting_input with
the structured question (prompt/why/options/entities); a panel answer resumed
the agent (it acknowledged host:strong and continued); a plain chat reply
auto-closed a second question. Cleanup + tests green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,10 @@ Each conversation is a **task**: a goal the operator wants achieved, from
|
||||
known problem.
|
||||
2. **Plan, then execute.** Gather what you need, propose a plan, get the single
|
||||
approval, and carry it out end-to-end (see the plan/approval sections below).
|
||||
If you hit a genuine decision only the operator can make — an ambiguous
|
||||
target, a trade-off, missing information — call `ask_operator` with the
|
||||
options and the entities involved, then STOP and wait; their answer resumes
|
||||
you. Don't ask about things you can settle yourself with tools.
|
||||
3. **Finish explicitly with `complete_task`.** When the goal is verified done —
|
||||
or you've genuinely failed or only partially succeeded — call `complete_task`
|
||||
with the `outcome` (success/failure/partial) and a one-line `summary`. This
|
||||
|
||||
Reference in New Issue
Block a user