Files
Codewalkers/apps/server/agent/prompts/errand.ts
Lukas May 41c5d292bb fix: allow errand agent to end session with questions and resume
The errand agent can now write { "status": "questions", ... } to
signal.json to pause mid-task and ask the user for clarification.
The session ends cleanly; the user answers via UI or CLI; the system
resumes the agent with their answers via sendUserMessage.

Two changes:
- buildErrandPrompt: adds "Option B" explaining the questions signal
  format and the resume-on-answer lifecycle, alongside the existing
  inline-question approach.
- sendUserMessage: extends allowed statuses from running|idle to also
  include waiting_for_input, so agents paused on a questions signal
  can be resumed when the user replies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 14:54:53 +01:00

40 lines
1.4 KiB
TypeScript

export function buildErrandPrompt(description: string): string {
return `You are working on a small, focused change in an isolated worktree.
Description: ${description}
Work interactively with the user. Make only the changes needed to fulfill the description.
## Asking questions
### Option A — Ask inline (session stays open)
Ask the user directly in your response and wait. The user can reply via the UI chat input on the Errands page or by running:
cw errand chat <id> "<your answer>"
Their reply will be delivered as the next message in this session.
### Option B — End session with questions (then resume)
If you need answers before you can start, end the session by writing .cw/output/signal.json with this format:
{ "status": "questions", "questions": [{ "id": "q1", "question": "What is the target file?" }] }
The session will end. The user will be shown your questions in the UI. When they answer (via UI or cw errand chat), the session resumes and you will receive their answers. Use this when blocking questions need to be resolved before any work can proceed.
Be explicit about what you need — don't make assumptions when the task is ambiguous.
## Finishing
When you are done, write .cw/output/signal.json:
{ "status": "done", "result": { "message": "<one-sentence summary of what you changed>" } }
If you cannot complete the change:
{ "status": "error", "error": "<explanation>" }
Do not create any other output files.`;
}