Skip to content

feat(chat): Let Junior ask for user input with requestUserInput - #2149

Merged
dcramer merged 15 commits into
mainfrom
feat/slack-buttons
Oct 30, 2026
Merged

dcramer merged 15 commits into
mainfrom
feat/slack-buttons

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Add requestUserInput, a tool that lets Junior ask a person for input before it continues. The model does not build Slack blocks or UI. It describes the input it needs as a list of fields. Each surface then renders the request in a fixed way. This replaces the Slack-only slackButtonsPost tool from the first version of this PR. It also follows the direction in #2187: ask for user input, not only one question with labels.

Request shape

  • question (markdown) and 1–4 fields.
  • Each field has an id, a label, an optional description, and a kind:
    • choice: pick one of 2–10 options.
    • multi_choice: pick any of 2–10 options.
    • text: type a short answer.
  • Free text ("Other") is always allowed.
  • Limits come from Slack (75-character labels, 10 options for radio buttons and checkboxes), so one request renders the same everywhere. There is no confirm kind. A confirmation is a choice field with two options. Previews are not included.

Answer

  • The answer is the next message from the person. It is a normal user message, so the person who answers is the Actor of the next Turn. Their credentials and approval apply. The tool does not wait. After the call, the model ends the Turn with no reply.
  • A click or a submitted form sends one format, built by formatUserInputAnswer:
    Answer to request <tool call id>:
    Approach (approach): Rebase
    Checks (checks): Lint, Tests
    Other: Keep the commit history.
    
    The request id is the tool call id, and the tool result also returns it as request_id. The lines are plain text, without list markers. Slack parses input text as mrkdwn, and that drops list markers and blank lines.
  • Typing a reply still works. It closes the open request as a free-text answer.

Slack

  • One choice field with up to 5 options: one button per option, plus an Other… button. One click is the answer, and the buttons change to "@person chose X".
  • Other requests: one Answer button. It opens a modal form with radio buttons, checkboxes, or a text input for each field, plus an optional Other text input. Submitting the form is the answer, and the controls change to a summary of the answer.
  • The thread has one open request. A newer request replaces it and closes the old message ("Replaced by a newer question."). Clicks and forms on a replaced request do nothing. Only the first answer counts, also when only the queue wake fails after the answer is saved.
  • An answer has no Slack message of its own. Its Slack timestamp is the request message, and its id is slack-user-input-answer:<action_ts or view id>.

Web dashboard

  • The dashboard reads the open request from the transcript. The assistant event has the input, and the result event has the completed status. The dashboard joins them by tool call id. It parses the input with the same userInputRequestSchema.
  • A short choice request shows buttons. Other requests show a form above the composer that you submit once. Both send the same formatted answer. A later user message closes the request.

The tool is available in Slack Turns that a person started in a thread, and in web Turns. It is not available in automation runs, local runs, or Slack Turns without a person, because nobody can answer there.

Other changes

  • App Home "disconnect" handling moved without changes into ingress/slack-interactive.ts, so slack-webhook.ts stays under the 1,000-line limit.
  • New Slack outbound helpers: updateSlackMessage (chat.update) and openSlackModal (views.open, one attempt, because a trigger_id works once).

Not in this PR

  • Automations and child conversations (Let a conversation coordinate child conversations #2105) cannot ask for input yet. The later design can use the same contract: post the request to a Destination, and send the answer to that Conversation as an inbound message.
  • There is no eval for when the model chooses to ask. It has not been tested in a live Slack workspace yet. The modal and view_submission path in particular needs a live check. The dashboard form has not had a visual QA pass.

Checks

  • tsc for @sentry/junior and @sentry/junior-dashboard, pnpm --filter @sentry/junior lint, dashboard lint, file-length, dashboard-style, test-architecture, tool-annotations, tool-error-classification, and ast-grep checks pass.
  • tests/integration/slack/user-input-click-webhook.test.ts (with a new form submit case), tests/unit/slack/slack-user-input.test.ts, tests/unit/slack/tool-registration.test.ts, and junior-dashboard/tests/user-input-request.test.ts pass.
  • In the sandbox, some unrelated Slack suites (slack-schedule-tools, watched-message-behavior, bot-image-hydration) time out at 5s, and a different set fails on each run. CI is the reference for those.

via David Cramer.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 30, 2026 11:05pm UTC

Request Review

@runningcode
runningcode marked this pull request as ready for review October 15, 2026 15:12
@runningcode
runningcode requested a review from dcramer October 15, 2026 15:12
@github-actions github-actions Bot added the risk: high PR risk score: high label Oct 15, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@sentry-junior sentry-junior Bot changed the title feat(slack): Let Junior post buttons and act on clicks feat(chat): Let Junior ask for a choice with requestUserInput Oct 16, 2026
@sentry-junior
sentry-junior Bot force-pushed the feat/slack-buttons branch from 0eebbc2 to 9d4b603 Compare October 16, 2026 13:07

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

sentry-junior Bot and others added 8 commits October 19, 2026 09:04
Add a slackButtonsPost tool that posts a message with one row of
buttons to the active Slack thread. The first click on a button
message becomes mention input from the person who clicked, so it
starts a new Turn in that thread with the button label and value.
Junior then replaces the buttons with that person's choice.

Move App Home interactivity into ingress/slack-interactive.ts so
slack-webhook.ts stays under the file length limit.

Co-Authored-By: Nelson Osacky <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
Give a click a non-timestamp id so every Slack timestamp reader
resolves the button message. Keep the click claim when the mailbox
saved the click and only the queue wake failed, because heartbeat
recovery still runs that click.

Co-Authored-By: David Cramer <[email protected]>
…uttons

Replace the Slack-only slackButtonsPost tool with a provider-neutral
requestUserInput tool. The model supplies only a question and 2-5 choice
labels with optional notes. Each surface renders them in a fixed way:

- Slack posts the question with one button per choice. The first click
  sends the choice label as a reply from the person who clicked.
- The web dashboard reads the open request from the transcript and shows
  the choices above the composer. A click sends the label as a message.

Typing a reply also answers the question on both surfaces.

Co-Authored-By: David Cramer <[email protected]>
Reporting puts the requestUserInput input on the running assistant event
and the completed status on the later result event. Keep the input by
tool call id until the result arrives, and open each request only once.

Co-Authored-By: David Cramer <[email protected]>
Main now keeps the tool list the same for every Turn in a Conversation,
so the provider cache stays valid. Register requestUserInput everywhere
and disable it, instead of removing it, when no person can answer: only
web Turns and Slack message Turns can ask.

Co-Authored-By: David Cramer <[email protected]>
A typed reply answers a requestUserInput question, but its buttons stayed
active, so a later click started a second Turn. The tool now records the
open question of the thread. A message to Junior in that thread claims
the question and replaces the buttons, so a later click does nothing.

Co-Authored-By: David Cramer <[email protected]>
A typed reply claimed the open question only after Junior saved it,
while a click claimed before it saved. When the queue wake failed after
the save, or a click came while the reply was saved, the click became a
second answer and the buttons stayed.

Claim the question before the reply is saved, the same order as a click.
Release the claim only when Junior did not save the reply. Keep the
open-question record, since the claim already blocks a second answer.

Move SlackEventPersistenceError to its own module to keep the webhook
file under the line limit.

Co-Authored-By: David Cramer <[email protected]>
requestUserInput now takes fields: choice, multi_choice, or text. Free
text is always allowed. Slack keeps one-click buttons for one short
choice field and opens a modal form for other requests. The web
dashboard shows the same form above the composer. Both send one answer
format that names the request id (the tool call id) and each field.

Refs #2187

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the feat/slack-buttons branch from 737c25b to 2d7177c Compare October 19, 2026 09:25
@sentry-junior sentry-junior Bot changed the title feat(chat): Let Junior ask for a choice with requestUserInput feat(chat): Let Junior ask for user input with requestUserInput Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

5 screenshot changes — 5 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed
Conversation Child Agent Drawer · Desktop
Conversation Child Agent Drawer · Desktop
Changed
Conversation Child Agent Drawer · Mobile
Conversation Child Agent Drawer · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed

CodeQL flagged /\s*\n\s*/g in answerLine: on a long run of spaces with
no newline it backtracks in quadratic time, and the input comes from
the person's answer. Split on newlines and trim each line instead. The
output is the same, and the time is linear.
Move duplicate id and label checks into userInputRequestSchema, so the
tool, Slack state, and the dashboard share one validation. Build closed
Slack messages from the request text instead of filtering blocks, parse
form metadata with zod, and drop unused exports.

Co-Authored-By: David Cramer <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

…oard

A dashboard message to a Slack conversation only appended web input. It
did not claim the open request of the Slack thread, so the buttons stayed
and a later click started a second Turn for the same request.

Send web messages to Slack conversations through the same claim as a
typed Slack reply. The first answer wins, and the buttons change to a
note that names the dashboard. The thread comes from the Conversation
Location, because the Slack Destination is only the channel.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

…ails

The dashboard path released the Slack request claim on every failed
append. A queue send can fail after the mailbox saved the message, so a
later click or a retry could add a second answer.

Check the mailbox for the web Message id before releasing the claim,
the same rule the Slack reply path uses. Let isSaved be async for this
check.
@sentry-evals

sentry-evals Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-guardian

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 94 0 0 $0.03 0 24.70s

Base commit eaeb050 has no eval run to compare against.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28beb8d. Configure here.

A newer requestUserInput call no longer marks an answered question as
replaced. It claims the older request first, so only an unanswered
question loses its controls, and a late click cannot answer it.

The dashboard question card now locks on the first click with a ref, so
a fast second click cannot send a second answer before React renders the
disabled controls. A failed send unlocks it for a retry.

Also rename the claim owner to claimedBy and flatten two control-flow
spots in the Slack webhook.

Co-Authored-By: David Cramer <[email protected]>
A child agent already lost requestUserInput through its agent_invocation
Source, but only by accident. Disable it by parent Conversation instead,
so no child Turn can post a question. Nobody sees a child transcript, and
a Slack answer would land in the parent's thread. The disabled reason
tells the child to use reportBlocked so the parent can ask.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 0732bae into main Oct 30, 2026
45 checks passed
@dcramer
dcramer deleted the feat/slack-buttons branch October 30, 2026 23:16
dcramer added a commit that referenced this pull request Oct 31, 2026
First PR of the review desk stack for #2401. It adds the Review item
records and the agent tools. There is no UI yet.

A Review item is work that needs a person. A `notice` only tells someone
something. An `action` asks for an answer with the same request shape as
`requestUserInput` (#2149). Each item has assignees (Users or Everyone),
an optional subject such as a pull request, and links to Conversations.
The adding Conversation is always linked.

Agents use three deferred tools in a new `review-desk` source:

- `addReviewItem` adds an item. If an open item already has the same
`dedupe_key`, it updates that item, so repeated Automation runs keep one
item and add their Conversation to its links.
- `updateReviewItem` changes an open item or closes it as `done` or
`dismissed` with a reason. It cannot submit an answer. Only an assignee
can.
- `searchReviewItems` finds items by subject, status, assignee,
Automation, or Conversation.

Visibility rules: an item linked to a private Conversation is private.
Only its assigned Users can see it, and it cannot be assigned to
Everyone. Agents can only see and change items that are public, that are
assigned to their Actor, that are linked to their Conversation, or that
their Automation added. Child agents cannot use these tools; they report
to their parent with `reportBlocked`.

"Review item" is the new term, because `TERMINOLOGY.md` already uses
"Item" for a linked object.

The later PRs in the stack add person actions and messages to linked
Conversations, the review desk page, and the in-Conversation and Slack
cards.

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1793326028.695969 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1793326028.695969)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1793326028.695969/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
dcramer added a commit that referenced this pull request Oct 31, 2026
Part 5 of the review desk stack for #2401. Stacked on #2466.

- **Card in linked Slack threads:** when an agent adds an open item,
each linked Slack thread gets a card. The controls reuse the #2149
`requestUserInput` rendering: one button per option for a single
`choice` field, otherwise an **Answer** button that opens the same form.
A notice shows **Done**. Every card shows **Dismiss** and links to the
item on the review desk.
- **Updates in place:** `junior_review_item_slack_cards` stores the
message of each card. After every agent update or close and every person
action (Slack, review desk, or Conversation card), each card changes in
place. A closed card has no controls and shows who closed it and the
answer.
- **Clicks act as the person:** a click needs the same workspace and
allowed-domain checks as a Slack mention, plus a Junior User linked to
the Slack account. It calls `actOnReviewItem` as that User, so the first
action still closes the item everywhere. The thread of the card gets the
action as Slack input from the person, like an answer to
`requestUserInput`. The other linked Conversations get the usual
messages (`exceptConversationId` keeps the thread from getting a second
copy). A click on a closed or forbidden item gets an ephemeral note and
refreshes the card.
- **Privacy:** a private item shows a card only in the thread that added
it, because other linked threads can have people who cannot see its
source. A card in a thread that can no longer show the item loses its
content.
- **Best effort:** a card failure is logged
(`review_item.slack_card.sync.failed`) and never fails the item change.

Small refactors: `buildSlackUserInputForm` takes the callback id and
metadata, so both forms share one builder. `slackUserInputAnswerNote`
takes `who` text instead of a Slack user id, because a Review item
closer is a Junior User. The Slack input that a click makes moved to
`chat/ingress/slack-interaction-input.ts` so both handlers build it the
same way.

Tests: `tests/integration/slack/review-item-card-webhook.test.ts` covers
the click flow (cards in two threads, first click closes both, a stale
click does nothing) and a private item (card only in the adding thread,
only an assignee can act).

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1793326028.695969 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1793326028.695969)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1793326028.695969/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ecebc1da Deployed Oct 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants