Skip to content

Let a message decline pending approvals and redirect the agent - #7907

Closed
lanjak wants to merge 2 commits into
get-bb:mainfrom
lanjak:feat-send-during-approval
Closed

lanjak wants to merge 2 commits into
get-bb:mainfrom
lanjak:feat-send-during-approval

Conversation

@lanjak

@lanjak lanjak commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

While a thread waits on an approval, the composer hides its editor and blocks sending (buildFollowUpSubmitMode returns blocked: pending-interaction). To redirect the agent, the user has to click Deny, wait, and then type. The agent often raises the next approval before the user can send the redirect, as #6666 describes. Approval resolutions carry no text, so the typed message has to reach the agent after the denial.

What changed

  • Server: declinePendingApprovals: true on POST /threads/:id/send (SDK threads.send) first checks the turn-bound interactions in pending status. If one is a question, a plugin form, or an approval without a deny decision, it returns 409 awaiting_user_interaction and declines nothing. Then it dispatches normally. Only when the existing dispatch logic queues the message with waitingOn: interaction does it deny each approval through resolvePendingInteraction, the same path the Deny button uses. The message is delivered when the denials resolve. A send that fails declines nothing. An approval answered between the check and the denial (409 conflict) is skipped, and the message stays queued. Any other deny error, such as a disconnected host, fails the request, so the caller does not see success while the approvals stay pending. A question that appears during dispatch is skipped; the message waits behind it. It returns 400 when combined with compactFirst, sendAt, mode: "start", mode: "queue-if-active" or /clear. Without the flag nothing changes, so a bb thread tell from another agent can never decline a user's approval by accident.
  • Composer: classifyFollowUpPendingInteractions (client-core) returns approvals when every pending interaction is an approval that offers deny, including plan approvals. Then the submit mode is queue with declinesPendingApprovals: true. The editor stays visible under the approval card, with the placeholder "Send a message to decline and redirect the agent" and the send title "Decline and send (Enter)". Enter sends steer-if-active with the flag, also with "steer on Enter" on. The modifier shortcut, scheduled sends and standalone /compact and /clear do not decline. A pending question or plugin form still hides the editor, as before.
  • CLI: bb thread tell --decline-approvals. The SDK passes the field through sendJson, which the app uses too.
  • Docs: bb guide thread-messaging. The contract allowlist entry for optional send fields now names the new field.
  • Out of scope: approving with a note (the second half of Pending approval or elicitation blocks the composer, so you can't deny with a reason or approve with conditions #6666).

There are no daemon wire changes.

How you verified

  • New tests:
    • public-thread-decline-approvals.test.ts: two approvals are denied and the message is delivered as turn.submit once they resolve. Without the flag, approvals stay pending. A pending question or an approval without deny gives 409 and nothing is declined or queued. A send that fails in dispatch (an unsupported permission mode) leaves the approval pending. An approval answered during the denial loop does not stop the others or the queued message. A deny that fails for another reason fails the send. The invalid combinations are rejected.
    • client-core: the classification (command and plan approvals, a question, no deny, resolving), the submit mode, and the request, also for /compact and /clear.
    • ThreadDetailPromptArea: the editor shows and the send carries the flag. A question keeps it blocked.
    • FollowUpPromptBox: the editor shows while declining. Enter uses the normal send with "steer on Enter" on.
    • CLI tell --decline-approvals: this also covers the SDK mapping.
  • Each guard has a test that fails when the guard is removed (checked one at a time), including denying before dispatch, the per-approval error handling, the deny check, and the built-in command check. One check found that the SDK's sendJson would have dropped the flag for the app.
  • pnpm exec turbo run typecheck lint lint:type-aware test for @bb/server-contract, @bb/server, @bb/client-core, @bb/app, @bb/cli, @bb/sdk and @bb/templates: all pass, except two local failures that also fail on main (UpdatePluginDialog date text and plugin-scaffold-external npm EALLOWSCRIPTS). LazyQueuedMessagesList timed out once under the full parallel run and passes on its own.
  • Live, in the isolated QA instance (pnpm --filter @bb/qa standalone:start) with a real Claude Haiku thread in accept-edits mode, asked to run touch outside the sandbox:
    • CLI: bb thread tell --decline-approvals "... Reply with REDIRECTED". The send was queued with waitingOn: interaction. The approval went from pending to resolved with deny. The command never ran, and the agent answered "REDIRECTED".
    • Real composer in a browser (Vite app against the same server), on a second approval. The editor showed under the approval card with the new placeholder. Typing and pressing Enter sent steer-if-active with declinePendingApprovals: true. The approval was denied, the file was not created, and the agent answered "UIREDIRECTED". This run also found that "steer on Enter" disabled the send while declining. That is fixed, and a test covers it.

Fixes #6666

AGENT GENERATED

While a thread waits only on approvals, the composer stays usable. Sending
denies the approvals through the Deny path once the message is queued behind
them, and the message reaches the agent when the denials resolve. Questions,
plugin forms and approvals without deny still block. The server takes
declinePendingApprovals on send, the CLI takes bb thread tell
--decline-approvals.

Fixes get-bb#6666
@lanjak

lanjak commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Closing this for now. The feature needs maintainer sign-off on #6666 first. The branch stays on my fork as a prototype, linked on the issue.

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.

Pending approval or elicitation blocks the composer, so you can't deny with a reason or approve with conditions

1 participant