Skip to content

Add the App assistant public API to AppService - #941

Open
Michael Lee (michaellee1019) wants to merge 8 commits into
mainfrom
cursor/app-assistant-proto-b580
Open

Michael Lee (michaellee1019) wants to merge 8 commits into
mainfrom
cursor/app-assistant-proto-b580

Conversation

@michaellee1019

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

Copy link
Copy Markdown
Member

Adds the assistant (the chat on the web app and on Viam mobile) to the existing AppService. The messages live in a new proto/viam/app/v1/assistant.proto (same viam.app.v1 package), imported by app.proto. Putting the RPCs on AppService means they ride the routes the load balancer already has, so no new service routing is needed.

RPCs on AppService

  • StreamAssistantTurn is the only turn RPC. The server owns the transcript, so a request carries either the user's new message or the result of one tool the client ran. The stream sends text deltas, a tool_status for each backend tool, and a usage event once the model has run. It ends on complete or on one client_tool for the client to run.
  • ListAssistantConversations lists the caller's conversations, newest updated_at first, one page at a time (page_size, page_token, next_page_token).
  • GetAssistantConversation returns the transcript, whether a turn is running, the client tool the conversation is waiting on, the stored conversation context, and the conversation's model.
  • ListAssistantModels lists the models a conversation can use and the default.

For mobile clients

  • Narration and answer. Each AssistantTextDelta has a block_index; a new index starts a new text block. AssistantTurnComplete.answer_block_index is the first block of the final answer. Blocks before it are narration between tool calls.
  • Reopening a conversation. A transcript entry is one user message or the assistant's whole reply to it. A reply has its steps in order (narration, and tool calls with the same name and label as the stream's tool_status), its answer in text, and worked_for, the time from the user's message to the answer.
  • Backgrounding. A turn runs to the end on the server when the client disconnects. GetAssistantConversation.running and AssistantConversationListItem.running say a turn is in progress, and the steps stored so far are in the transcript. A client polls until running is false. A message sent meanwhile fails with TURN_RUNNING.
  • Typed errors. A failed assistant RPC carries an AssistantError in its gRPC status details, whose AssistantErrorReason covers: conversation too long, turn running, conversation changed, turn failed, assistant unavailable, no billing organization, unknown model, no client tool waiting, and empty input. AssistantTurnComplete.stop_reason is the AssistantStopReason enum. Clients never match message text.

Models and cost

  • StreamAssistantTurnRequest.model picks a model from ListAssistantModels. The conversation keeps it for later turns, and an empty value keeps the current pick.
  • AssistantTurnUsage reports the model that served the turn and the paying organization's month-to-date AI cost. The cost is set only for a caller who may see that organization's billing. Billing is entirely server side; a client does nothing for it.

Notes

  • There is no approval flow. A staged config change is confirmed with the builder's Save, and backend tools run on the call. Since the API is unreleased, field numbers of removed or retyped fields are reused (stop_reason changed from a string to an enum in place).
  • Generated Go stubs are included. JS bindings come from CI once the PR is labeled ready-for-protos.
  • The app server consumes this through a go.mod replace on viamrobotics/app#14301.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1

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>
@viambot viambot added the safe to test committer is a member of this org label Nov 6, 2026
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>
@viambot viambot removed the safe to test committer is a member of this org label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

For security reasons, this PR must be labeled with safe to test in order for tests to run.

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
@viambot viambot added the safe to test committer is a member of this org label Nov 20, 2026
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
@michaellee1019 Michael Lee (michaellee1019) changed the title Add the App assistant public API Add the App assistant public API to AppService Nov 20, 2026
- 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
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