Skip to content

App assistant: StopAssistantTurn - #956

Closed
Michael Lee (michaellee1019) wants to merge 14 commits into
mainfrom
cursor/assistant-stop-and-client-b580
Closed

Michael Lee (michaellee1019) wants to merge 14 commits into
mainfrom
cursor/assistant-stop-and-client-b580

Conversation

@michaellee1019

@michaellee1019 Michael Lee (michaellee1019) commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

A follow-up to the App assistant API in viamrobotics/api#941. This branch is based on #941, so until that merges the diff includes it. The changes this PR adds are its own commits.

Stopping a turn

A turn keeps running on the server after its stream closes, so a phone can background without losing the reply. That also means closing the stream no longer stops it. A server-streaming RPC takes a single request, so there is no way to send "stop" on the same stream.

  • StopAssistantTurn(conversation_id) stops the turn running in one of the caller's conversations.
    • A tool call already running finishes, and nothing after it starts.
    • The turn ends with the new ASSISTANT_STOP_REASON_STOPPED, and the steps it finished are kept.
    • Stopping a conversation with no turn running does nothing.

https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1


Generated by Claude Code

AppAssistantService is the shared chat contract for the web app and Viam mobile: one server stream for a turn, plus list and get for the server-owned transcript. Approval and client-tool pauses end the stream so a phone can drop the connection while a person decides.

Co-authored-by: Michael Lee <michaellee1019@gmail.com>
GetConversationResponse now returns the open client tool and the stored
conversation context. ApprovalRequired carries a structured diff. List
conversations is defined as newest updated_at first.

Co-authored-by: Michael Lee <michaellee1019@gmail.com>
The app server never sends approval_required and refuses an approval
input: a staged change is confirmed with the builder's Save, and backend
writes run on the call. The API is unreleased, so the remaining fields
take the freed numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
ListModels lists the models a conversation can use, and StreamTurn takes
one in model. Each stream that ran the model reports the conversation's
billed cost and, to a caller who may see it, the paying organization's
month-to-date AI cost. GetConversation returns the conversation's model
and cost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
The per-conversation cost is dropped from TurnUsage and GetConversation.
The API is unreleased, so the remaining field takes the freed number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
The four RPCs move from their own AppAssistantService into AppService as
StreamAssistantTurn, ListAssistantConversations, GetAssistantConversation
and ListAssistantModels, so the app's existing routes carry them. Their
messages move into viam.app.v1 with an Assistant prefix, and the stream's
response is StreamAssistantTurnResponse, so the lint exception goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
- A text delta carries its block index, and complete names the first
  block of the final answer, so a client can collapse the narration.
- A transcript reply holds its steps (narration and tool calls) and how
  long it took, so a reopened chat shows the work behind each answer.
- GetAssistantConversation and the list say whether a turn is running.
  A turn finishes on the server when the client disconnects.
- Failed RPCs carry an AssistantError detail with a typed reason, and
  the stop reason is an enum, so clients never match message text.
- ListAssistantConversations is paginated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
AssistantMessageRole replaces the free-form "user" / "assistant" string,
so clients branch on a typed value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
- StopAssistantTurn stops the turn running in a conversation, which a
  client cannot do by closing a stream that the turn outlives. The turn
  ends with ASSISTANT_STOP_REASON_STOPPED.
- StreamAssistantTurnRequest.client names the app the user chats from, so
  the assistant describes where it is and asks only for client tools that
  app runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
@viambot viambot added the safe to test committer is a member of this org label Nov 30, 2026
The assistant goes by the conversation context alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
@michaellee1019 Michael Lee (michaellee1019) changed the title App assistant: StopAssistantTurn and the calling client App assistant: StopAssistantTurn Nov 30, 2026

Copy link
Copy Markdown
Member Author

Folded into #941 at your request: its branch now includes this PR's commits (StopAssistantTurn and ASSISTANT_STOP_REASON_STOPPED). Closing this one.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test committer is a member of this org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants