Skip to content

[APP-18758] Add the App assistant public API to AppService - #941

Merged
Michael Lee (michaellee1019) merged 23 commits into
mainfrom
cursor/app-assistant-proto-b580
Dec 2, 2026
Merged

Michael Lee (michaellee1019) merged 23 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. It is the only assistant API: the web chat will move onto it, and the app's FleetDashboard assistant RPCs will be deleted. 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). It can filter by organization, robot_id or fragment_id.
  • GetAssistantConversation returns the transcript, whether a turn is running, the client tool the conversation is waiting on, the stored conversation context, the conversation's model, and how the last turn ended (stop_reason).
  • ListAssistantModels lists the models a conversation can use and the default.
  • SubmitAssistantFeedback grades one of the caller's conversations, with a required comment.
  • GetAssistantUsage returns the paying organization's month-to-date AI cost for a context before any turn runs, with the same visibility rule as usage.
  • StopAssistantTurn stops the turn running in one of the caller's conversations. Closing the stream does not stop a turn (see Backgrounding), and a server-streaming RPC takes one request, so stopping needs its own call. A tool call already running finishes, and nothing after it starts. The turn ends with ASSISTANT_STOP_REASON_STOPPED, and the steps it finished are kept.

Client tools and tool results

  • client_tools. A caller names the client tools it runs. The model is offered only those, and client_tool is sent only for them. Empty offers none, which is what mobile sends today. Names the server does not know are ignored, so a client newer than the server keeps working.
  • tool_result. When a backend tool finishes, the stream sends its tool_use_id, input, result (cut to 64 KiB, with truncated), is_error, and the final marker label. tool_status carries the same tool_use_id. A client can react to what a tool did: for example, the web builder reloads after a config save. A transcript step is tool_result once a call has finished, for server and client tools alike. A tool step is a call with no result yet.

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. StopAssistantTurn ends it early.
  • Reading a reopened conversation. open_client_tool is set only while running is false. Poll while a turn runs, then run the open client tool if there is one.
  • 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.

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>
@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
@viam-overwatch

Copy link
Copy Markdown

Hey Michael Lee (@michaellee1019) — CI is green and no reviewer is assigned yet. Could you request one when you have a chance?

Auto-comment from overwatch. Will not re-nudge for 7 days.

@michaellee1019 Michael Lee (michaellee1019) changed the title Add the App assistant public API to AppService [APP-18758] Add the App assistant public API to AppService Nov 30, 2026
Comment thread proto/viam/app/v1/assistant.proto Outdated
// One user message, or the assistant's whole reply to one.
message AssistantTranscriptMessage {
// "user" or "assistant".
string role = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: could role be an enum, like the ConversationRole the web client already uses, instead of a free-form string?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, will update this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 3feccd3. AssistantTranscriptMessage.role is now AssistantMessageRole (UNSPECIFIED, USER, ASSISTANT), and the app server sends it as of viamrobotics/app@04ade8852.


Generated by Claude Code

message GetAssistantConversationResponse {
repeated AssistantTranscriptMessage messages = 1;
// Set when a turn is waiting on the client to run a tool. Empty otherwise.
AssistantClientTool open_client_tool = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is running false while open_client_tool is set? A client reopening the conversation needs to know whether to poll or run the tool.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, always. I think the client has everything it needs to know what to do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments for possible improvements, no dealbreakers, so LGTM.

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
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) added the ready-for-protos add this when you want protos to compile on every commit label Nov 30, 2026
- client_tools: the caller names the client tools it runs; only those
  are offered to the model.
- tool_result: a finished backend tool's input, result and final label,
  streamed and stored as a transcript step; tool_status carries the
  matching tool_use_id.
- GetAssistantConversation returns the last turn's stop_reason.
- ListAssistantConversations filters by robot_id or fragment_id.
- SubmitAssistantFeedback and GetAssistantUsage RPCs.
- open_client_tool is documented as set only while running is false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
client_tools now carries each tool's definition (name, description, input
JSON Schema, optional transcript title) instead of names the server had to
know, so any client, such as a mobile app, can offer its own tools. A
client_tool call can come from the model or from a tool-chain subagent.

- client_instructions adds the client's guidance about its tools to the
  model's instructions.
- ASSISTANT_ERROR_REASON_INVALID_CLIENT_TOOLS rejects a malformed or
  oversized definition, or one that reuses a server tool's name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
AssistantConversationContext.inline_module_id names a Viam-hosted module, and
ListAssistantConversationsRequest filters by it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
@michaellee1019
Michael Lee (michaellee1019) merged commit 8ab89a2 into main Dec 2, 2026
1 check passed
@michaellee1019
Michael Lee (michaellee1019) deleted the cursor/app-assistant-proto-b580 branch December 2, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

protos-compiled ready-for-protos add this when you want protos to compile on every commit safe to test committer is a member of this org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants