Repository navigation
[APP-18758] Add the App assistant public API to AppService - #941
Conversation
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>
|
For security reasons, this PR must be labeled with |
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
|
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. |
| // One user message, or the assistant's whole reply to one. | ||
| message AssistantTranscriptMessage { | ||
| // "user" or "assistant". | ||
| string role = 1; |
There was a problem hiding this comment.
Nit: could role be an enum, like the ConversationRole the web client already uses, instead of a free-form string?
There was a problem hiding this comment.
Agreed, will update this.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Is running false while open_client_tool is set? A client reopening the conversation needs to know whether to poll or run the tool.
There was a problem hiding this comment.
Yes, always. I think the client has everything it needs to know what to do.
Petr Novikov (petrnovikov)
left a comment
There was a problem hiding this comment.
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
…viamrobotics/api into cursor/app-assistant-proto-b580
- 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
- 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
…viamrobotics/api into cursor/app-assistant-proto-b580
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
…viamrobotics/api into cursor/app-assistant-proto-b580
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 newproto/viam/app/v1/assistant.proto(sameviam.app.v1package), imported byapp.proto. Putting the RPCs onAppServicemeans they ride the routes the load balancer already has, so no new service routing is needed.RPCs on
AppServiceStreamAssistantTurnis 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, atool_statusfor each backend tool, and ausageevent once the model has run. It ends oncompleteor on oneclient_toolfor the client to run.ListAssistantConversationslists the caller's conversations, newestupdated_atfirst, one page at a time (page_size,page_token,next_page_token). It can filter by organization,robot_idorfragment_id.GetAssistantConversationreturns 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).ListAssistantModelslists the models a conversation can use and the default.SubmitAssistantFeedbackgrades one of the caller's conversations, with a required comment.GetAssistantUsagereturns the paying organization's month-to-date AI cost for a context before any turn runs, with the same visibility rule asusage.StopAssistantTurnstops 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 withASSISTANT_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, andclient_toolis 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 itstool_use_id, input, result (cut to 64 KiB, withtruncated),is_error, and the final marker label.tool_statuscarries the sametool_use_id. A client can react to what a tool did: for example, the web builder reloads after a config save. A transcript step istool_resultonce a call has finished, for server and client tools alike. Atoolstep is a call with no result yet.For mobile clients
AssistantTextDeltahas ablock_index; a new index starts a new text block.AssistantTurnComplete.answer_block_indexis the first block of the final answer. Blocks before it are narration between tool calls.stepsin order (narration, and tool calls with the same name and label as the stream'stool_status), its answer intext, andworked_for, the time from the user's message to the answer.GetAssistantConversation.runningandAssistantConversationListItem.runningsay a turn is in progress, and the steps stored so far are in the transcript. A client polls untilrunningis false. A message sent meanwhile fails withTURN_RUNNING.StopAssistantTurnends it early.open_client_toolis set only whilerunningis false. Poll while a turn runs, then run the open client tool if there is one.AssistantErrorin its gRPC status details, whoseAssistantErrorReasoncovers: 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_reasonis theAssistantStopReasonenum. Clients never match message text.Models and cost
StreamAssistantTurnRequest.modelpicks a model fromListAssistantModels. The conversation keeps it for later turns, and an empty value keeps the current pick.AssistantTurnUsagereports 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
stop_reasonchanged from a string to an enum in place).ready-for-protos.go.modreplace on viamrobotics/app#14301.https://claude.ai/code/session_01JLuWqczk3u5gmMh7nSxMA1
Generated by Claude Code