Skip to content

Add clarifying-questions step to the dispatch wizard (PK-283) - #64

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/pk-283-wizard-clarification
Draft

Add clarifying-questions step to the dispatch wizard (PK-283)#64
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/pk-283-wizard-clarification

Conversation

@posthog

@posthog posthog Bot commented Jul 26, 2026

Copy link
Copy Markdown

Summary

The interactive dispatch wizard (src/commands/dispatch-interactive.ts) previously only checked that the task string wasn't empty before forwarding it to dispatch() — a vague, ambiguous, or risky instruction was dispatched as-is, burning an agent run on throwaway work.

This adds an optional LLM-backed clarification step between the task prompt and the confirm/dispatch:

  • Reviews the instruction, surfaces concerns, and offers to answer a few clarifying questions that get folded back into a refined prompt.
  • Follows the repo's existing port pattern: ClarifierPort behind an interface, a real port wrapping the Anthropic SDK, and pure parseAssessment/refinePrompt helpers that are unit-tested with fakes (no key needed).
  • Fail-open: a missing Anthropic key or any error leaves the original prompt untouched, so a dispatch is never blocked.

It also adds best-effort PostHog instrumentation (posthog-node) to the wizard, since the CLI previously captured nothing. Analytics no-ops when unconfigured (POSTHOG_API_KEY unset) and never throws.

Why

PK-283 (backlog): the wizard fires tasks off without ever pushing back on flawed or underspecified instructions. Catching those before spending an agent run is a quality win, and instrumenting the flow makes it measurable for the first time.

Test plan

  • npm test — 47 pass, including new test/clarify.test.ts covering JSON parsing (fences, malformed → fail-open, question cap) and prompt refinement.
  • npm run build and tsc --noEmit clean.
  • Runtime smoke: analytics capture no-ops without a key; clarifier parse/refine helpers produce expected output.

Created with PostHog Desktop from this inbox report.

The interactive dispatch wizard previously only guarded against an empty task
string, forwarding vague or risky instructions straight to the agent and burning
a run on throwaway work.

Add an optional LLM-backed clarification step between the task prompt and the
confirm/dispatch: it reviews the instruction, surfaces concerns, and offers to
fold answers to a few clarifying questions back into the refined prompt. The
check follows the repo's port pattern (ClarifierPort behind an interface, real
port wrapping the Anthropic SDK, pure parse/refine helpers unit-tested with
fakes). It is fail-open — a missing Anthropic key or any error leaves the
original prompt untouched so a dispatch is never blocked.

Also add best-effort PostHog (posthog-node) instrumentation for the wizard, since
the CLI previously captured nothing. Analytics no-ops when unconfigured and never
throws.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Generated-By: PostHog Code
Task-Id: 4dc8a91f-4df5-4258-9d18-d8dcd0c09977
@linear

linear Bot commented Jul 26, 2026

Copy link
Copy Markdown

PK-283

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polyagent Ready Ready Preview, Comment Jul 26, 2026 4:39am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants