Skip to content

feat: add multiple-choice question handling in assistant UI - #639

Merged
pikann merged 3 commits into
masterfrom
feature/add-multiple-choice-question-handling-for-agent
Oct 26, 2026
Merged

pikann merged 3 commits into
masterfrom
feature/add-multiple-choice-question-handling-for-agent

Conversation

@pikann

@pikann pikann commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Agents can now ask the user a multiple-choice question and get the answer with a click, in chat conversations and in task/document activity comments. The PR also makes tool calls show what they were given, turns plain-text @mentions into real mention badges, and notifies the user when an agent asks them something in a conversation.

Changes

Tool calls show their input

  • Conversation events now fill the tool call's args from ACP rawInput (and later updates), instead of an empty string.
  • The collapsed tool header shows a one-line summary of the input (command, file path, query, …); the expanded card shows a shell command verbatim as $ <command>.

ask_user_question tool

  • MCP (apps/mcp/src/tools/ask-tools.ts): takes question, options, optional multiSelect and mention. In chat it returns immediately and echoes the question in its result (some runtimes, e.g. Goose-wrapped CLIs, report an empty tool input). With projectId + taskId/docId it posts the question as a task or document comment.
  • Chat: AskQuestionCard shows the options plus a free-text field; picking one sends it as the user's next message. The card sits outside the collapsible tool group, so it is visible without expanding anything. The tool name match also covers Goose-style titles such as mcp: paca ask user question.
  • Comments: the shared ActivityPane renders the question embedded in a comment (a paca-ask code block) as the same card; the answer is posted as a reply that @-mentions the asking agent, so the existing mention trigger wakes it. The card disables once someone else has replied.

Mentions render as badges

  • Agents write @username or @Name (id: …) as plain text, which the API ignored. The activity service now links these to project members as teamMention chips on add/edit of task and doc comments (agent id for agent members, user id otherwise). Unknown names, emails, inline code and code blocks are left alone.
  • The task activity service now reads mentions from the stored content so linked agents are actually triggered.
  • The MCP task-comment client does the same resolution, and add_task_comment documents @username.

Agents @-mentioned in document comments are triggered

  • Doc comments previously had no mention trigger, so answering a question on a document could never resume the agent. docsvc.ActivitySvc now starts a conversation for each @-mentioned agent (TriggerDocCommentMention on the agent service and trigger gate, same permission check as task comments; self-mentions are ignored).
  • The conversation has no task; the trigger carries document_id. agent-runner decodes it and tells the agent the Document ID (LLM and ACP prompts, and the ACP bridge dispatch).
  • A person @mentioned in a doc comment now gets an in-app notification (NotifyDocCommentMentioned; migration 000075_add_document_notifications.sql adds document_id), plus the existing notification.doc_mentioned plugin event. The bell shows "X mentioned you in document <title>" and opens the document. Self-mentions and non-members are skipped.
  • When ask_user_question is given a task/doc but no mention, the MCP server mentions whoever started the conversation (by member id), so the agent doesn't need list_project_members.

Notification when an agent asks a question in a conversation

  • New consumer question_notification_consumer.go reads the conversation event stream (paca:agent:events), detects the ask tool's result, and notifies the conversation's owner (the global-chat user, or the triggering project member). No agent-facing endpoint is involved.
  • Migration 000074_add_question_notifications.sql: adds conversation_id, allows the question type, and makes project_id optional (global chat has no project).
  • The notification bell shows "X asked you a question in <title>", labels global chats, and opens the right conversation (global or project).

i18n

  • New strings in all 9 locales (shared.json for the card, appShell.json for the notification).

Notes

  • Questions asked before the new consumer starts are not notified; conversations with no identifiable owner (e.g. automation-triggered) notify nobody.
  • Plain-text mention linking needs the API restarted. The agents' MCP server needs a rebuild/republish to pick up the new tool result text and mention field.

Testing

  • Go: go test ./internal/... (mention linking, NotifyQuestion, ask-result detection).
  • MCP: vitest run (ask tool, mention linking).
  • Web: tsc -b, vitest for tool args, ask parsing, rawInput conversion, assistant-ui, notification bell, i18n parity.
  • Not verified end to end in a running app.

🤖 Generated with Claude Code

- Introduced AskQuestionCard component for displaying multiple-choice questions from agents.
- Enhanced ToolFallback component to render AskQuestionCard when the tool call is of type `ask_user_question`.
- Implemented parsing and extraction of ask questions from tool call inputs and comment blocks.
- Added functionality to link mentions in comments to project members, allowing for structured team mentions.
- Updated internationalization files to support new ask question features in multiple languages.
- Added tests for ask question parsing and mention linking functionality.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The ask_user_question tool advertises document support, but answering a question posted on a document never resumes the agent — doc comments have no mention trigger. Details in the section below.

Reviewed changes — full pass over the 53-file diff (agent ask_user_question MCP tool, plain-text mention linking, question notifications, chat/comment question UI, tool-call input display, i18n).

  • ask_user_question MCP tool (apps/mcp/src/tools/ask-tools.ts) — chat mode returns immediately and echoes a paca-ask payload in the tool result; with projectId + taskId/docId it posts a paca-ask comment and returns immediately.
  • Comment question card (ask-question-card.tsx, activity-pane.tsx, ask-question.ts) — renders the embedded payload and posts the chosen answer as a reply that mentions the asking agent.
  • Chat question card (tool-fallback.tsx, thread.tsx) — keeps the ask call outside the collapsible tool group; the answer is appended as the user's next message.
  • Plain-text mention linking (services/api/.../activity/mentions.go, apps/mcp/.../converters.ts) — converts @username / @Name (id: …) text to teamMention chips; the task activity service reads the stored content so linked agents trigger.
  • Question notifications (question_notification_consumer.go, notification service/repo/DTO, migration 000074) — new question type, optional project_id, optional conversation_id; the bell opens the conversation (global or project).
  • Tool-call input display (conversation-to-thread-messages.ts, tool-args.ts) — ACP rawInput becomes argsText; the header shows a one-line summary.
  • i18n — new shared/appShell strings in all 9 locales.

⚠️ Answering a question on a document never wakes the agent

ask_user_question documents a docId path ("pass projectId plus taskId (or docId): the question is posted as a comment there and the user's choice comes back as a reply comment that @-mentions you"), and ActivityPane will happily render the card and post the reply on a document. But doc comments have no mention trigger: only task/activity_service.go's AddComment calls handleMentions/TriggerCommentMention, while service/doc/activity_service.go's AddComment posts the comment and returns. So on a document the reply is recorded, the agent is never woken, and the question is effectively a dead end — the same symptom the task path avoids.

Technical details
# Doc-comment ask flow does not resume the agent

## Affected sites
- `apps/mcp/src/tools/ask-tools.ts:139` — the `docId` branch posts the question via `docClient.addDocumentComment`.
- `apps/web/src/components/shared/activity-pane.tsx:284` — `answerAsk` posts the answer as a reply carrying a `teamMention` of the asking agent.
- `services/api/internal/service/doc/activity_service.go:116` — `ActivitySvc.AddComment` never calls `handleMentions`, so nothing resolves the mention or triggers the agent for a doc comment.
- `services/api/internal/service/task/activity_service.go:167` — the task path does call `handleMentions`, which is why tasks work.

## Required outcome
- Answering a question posted on a document must resume the asking agent, or the tool must stop advertising `docId` support (and its description should say the answer is only recorded).

## Suggested approach
- Add mention handling for doc comments mirroring the task path (agent trigger + `NotifyDocMentioned`), or restrict `ask_user_question` to tasks and remove the `docId` branch until doc comments trigger agents.

## Open questions for the human
- Is doc-comment agent triggering intentionally out of scope here? If so, the `docId` option, its description, and `ALL_TOOLS.md` should state that the answer is recorded but does not resume the agent.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

- Introduced DocumentID in the Trigger struct to handle document comment mentions.
- Updated message building functions to include DocumentID when present.
- Enhanced notification system to create in-app notifications for users @mentioned in document comments.
- Implemented logic to trigger agent conversations when agents are mentioned in document comments.
- Added tests to verify the functionality of document comment mentions and notifications.
- Created a database migration to add the document_id column to the notifications table.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes — incremental delta since the prior pullfrog review (929596f9): the doc-comment mention path the previous review flagged as missing.

  • Doc-comment mentions now act — docsvc.ActivitySvc.handleMentions starts @-mentioned agents (TriggerDocCommentMention) and notifies @-mentioned people (NotifyDocCommentMentioned), so answering a question posted on a document now wakes the agent.
  • Doc trigger plumbing — TriggerDocCommentMention added to the agent service and the trigger gate; DocumentID threaded through the agent-runner trigger, decode, prompt, and ACP message/dispatch.
  • Doc notifications — document_id/document_title added to the notification domain, repository, and DTO (migration 000075); the bell renders and opens doc mentions.
  • Owner-mention default — ask_user_question now mentions the conversation's owner when mention is omitted.
  • Notification chime — redesigned to a two-note marimba motif.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 39aeee1 into master Oct 26, 2026
12 checks passed
@pikann
pikann deleted the feature/add-multiple-choice-question-handling-for-agent branch October 26, 2026 05:31
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.

1 participant