Skip to content

fix(examples): crew approvals come back in a reopened app - #2121

Merged
isekovanic merged 1 commit into
mainfrom
fix/crew-approvals-after-restart
Nov 19, 2026
Merged

isekovanic merged 1 commit into
mainfrom
fix/crew-approvals-after-restart

Conversation

@isekovanic

@isekovanic isekovanic commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Linear: AI-3392

Why

The crew app declared the tools that ask first (request_shift_swap, create_support_ticket, book_check_in) with the client executor. The router asks a client tool's question on its step only when it can address the phone, which the SDK can't name yet. So the question lived only on the session, shown by AgentNotices above the composer, and was lost when the app was closed while it waited. The SDK docs say to declare a tool that asks first with the server executor until then.

Changes

  • deviceTools.ts: those three tools are declared with the server executor, so the question is on the reply's step and comes back in a reopened app. The phone still runs them.
  • crewTools.ts: each names the argument its card shows (reasonArgument: the ticket's summary, the swap's note, the check-in's topic), since the step keeps no other arguments.
  • AgentNotices.tsx: the approval cards above the composer are gone, since the step shows the question. It keeps the failure notice.

Validation

Before merging

A reopened app needs #2119 deployed and a @stream-io/stream-agents release with #2120. Until then, this change only moves the card onto the step. Bump the app's @stream-io/stream-agents once that release is out.

The tools that ask first are declared with the server executor, as the SDK docs say,
so their question is on the reply's step, with a line from the call, and the card
above the composer that repeated it is gone.

AI-3392
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The approval configuration now maps each approval-gated tool to a reason argument. Tools with an approval entry use the server executor; other tools remain client executor tools. AgentNotices no longer renders approval requests or decision cards. It renders only the failure notice.

Merge Risk: Minimal · up to aaebf

This example-app change moves approval questions from a composer-area card onto the reply step and shows a more relevant reason on each approval card. No concrete defect was established in the changed code. Full reopened-app behavior depends on the router deployment and SDK release the author already lists, so the change is low-risk to merge.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0bacd97 and aaebfbb.

Files selected for processing: 3

  • examples/voice_agents/crew_assistant/app/agent/crewTools.ts
  • examples/voice_agents/crew_assistant/app/agent/deviceTools.ts
  • examples/voice_agents/crew_assistant/app/screens/AgentNotices.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

isekovanic added a commit that referenced this pull request Nov 19, 2026
…osed (#2119)

Linear: AI-3392

## Why

When an app was killed while a tool call waited for the person's
approval and then reopened, the question was gone: the conversation
showed "Thinking…" until the tool's timeout failed the call. This
affects every client SDK.

Two things lost it:
- The step's question reached the channel only through live (ephemeral)
updates, and Stream stored it once the reply settled. Connector calls
held for approval are stored at once (`AwaitApproval`), and tool calls
weren't.
- The call itself went only to the socket of the app that asked. A
reopened app had nothing to run when the person allowed it: a server
tool's step keeps no arguments, and Swift, Kotlin and Dart answer only
calls in their live `approvals`.

## Changes

- `Conversation.Observe` stores the reply when a tool call's step starts
waiting for the person (`awaiting_approval`) and when they answer, as
`AwaitApproval` does for connector calls.
- `Session.watch` sends a call still waiting for the person's approval
to a watcher that attaches later, with its command, as `askTool` sends
it, so the result is taken. A call the person already answered isn't
sent again, so nothing runs twice. This is the replay a resumed watcher
with a cursor and a voice tool host already get, for a client that comes
back without a cursor, such as a relaunched app. The calls are read
before `s.mu`, since the conversation broadcasts to the session under
its own lock.
- `DecideCommandTool` records the answer on the waiting call
(`bridge.decide`) before the conversation hears it, and `watch`
re-checks under `s.mu` that the call still waits for an answer
(`bridge.asking`). A call answered or finished between that read and the
send isn't sent.
- `Watch`'s comment says what is replayed now.
- A changelog entry under Unreleased bug fixes.

With this, each SDK's existing `decide` answers the re-sent call. The
JavaScript SDK also needs #2120 for an Allow tapped before the call
arrives, and the crew sample uses it in #2121.

## Validation

- New tests:
- `TestAToolsQuestionAndAnswerAreWrittenToChat`: the question and the
answer are in Chat.
- `TestACallWaitingForThePersonIsSentAgainToALaterWatcher`: a later
watcher gets the call with its arguments and command; one answered in
the window before the send, or answered for good, doesn't.
  - Each fails without its change, the race case without the re-check.
- `go test` of `internal/conversation`, `internal/session` and
`internal/api` passes, and so does `go test -tags integration` of the
same three packages (local Postgres and Redis).
- On the iOS simulator, in the crew React Native app against a router
built from this branch, with #2120 and #2121:
- asked for a repair ticket, killed the app while the card was up,
reopened the conversation: the card is back, Send for review runs the
tool on the phone (`POST /crew/tickets`), the router logs `outcome=ok`,
and the reply finishes with the ticket;
  - the same flow without a kill still shows one card and runs once.
- Swift, Kotlin and Dart get the re-sent call through the same path but
weren't run on a device.
@isekovanic
isekovanic merged commit ea915a9 into main Nov 19, 2026
18 checks passed
@isekovanic
isekovanic deleted the fix/crew-approvals-after-restart branch November 19, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants