Open
Conversation
Adds a new `clarification` agent tool that lets the model ask the user a focused question when the request is ambiguous (multiple plausible tables, unclear metric, etc.), mirroring the SOTA behaviour in Claude Code and Codex. - Shared zod schema (question + optional 2-5 options) in `apps/shared/src/tools/clarification.ts`. - Backend tool registered in `agents/tools`; the ToolLoopAgent stops when the tool is called so the user can reply. - System prompt instructs when to call the tool (only when guessing would be costly, never alongside other tools or suggest_follow_ups). - Frontend `ClarificationToolCall` renders a card with the question and clickable option chips that populate the chat input. Marked non-collapsible so it never gets folded into a tool group. - Clarification tool calls are excluded from messaging provider summaries.
Contributor
🚀 Preview Deployment
Preview will be automatically removed when this PR is closed. |
- Clicking an option chip now sends the answer directly via queueOrSendMessage instead of only filling the prompt. - Each clarification tool call now detects whether a user message has come in after it in the conversation. If so, it switches to an "Answered" state: chips are disabled and the selected option gets a checkmark and secondary style. This naturally supports multi-turn / multiple clarification questions — older cards remain visible as answered context. - Strengthened the system prompt + tool description to clarify the multi-turn flow (one question per call, ask the next on a later turn, never re-ask something already answered).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
clarificationagent tool + UI, mirroring the SOTA behaviour in Claude Code and Codex. When the user's request is genuinely ambiguous (multiple plausible tables, unclear metric, missing time range, etc.), the agent can call this tool to ask one focused question and optionally surface 2–5 clickable answer chips. The agent then stops and waits for the user's reply.UX
clarificationagain on the next turn; previous cards automatically switch to an "Answered" state (muted, checkmark on the selected chip) so the user keeps the full decision trail visible.suggest_follow_ups), so the assistant remembers what it asked.Walkthrough
Direct-send + multi-turn answered state:
clarification_v2_direct_send_and_answered_state.mp4
Initial clarification card with chips:
Clarification card with Quick question header and option chips
Clicking a chip sends it instantly (input stays empty, message appears as a user bubble):
Chip click sends directly
When a follow-up clarification fires, the previous card turns into an "Answered" card with a checkmark on the selected option:
Multi-turn state: previous card marked answered
What changed
apps/shared/src/tools/clarification.ts) — zod input{ question, options?: string[2..5] }.apps/backend/src/agents/tools/clarification.ts) — registered intools/index.ts; theToolLoopAgent'sstopWhennow also fires onclarificationso the run halts and waits for the user.suggest_follow_ups), and now explicitly cover the multi-turn flow: one question per call, ask the next on a later turn, never re-ask something already answered.ClarificationToolCallcomponent (apps/frontend/src/components/tool-calls/clarification.tsx):queueOrSendMessage({ text: option })from the agent context for immediate submission;NON_COLLAPSIBLE_TOOLSso it never gets folded into a tool group.tool-clarificationadded toEXCLUDED_TOOLSso Slack/Telegram/etc. summaries don't render raw tool entries for it.Testing
npm run lintnpm run -w @nao/backend test— 11 pre-existing failures onmain(system-prompt date tests, sqlite tests, compaction LLM); none related to this change.To show artifacts inline, enable in settings.