AI Technician: Streaming, recovery, and persistence

I built the AI Technician frontend and backend session services for long-running vehicle diagnostics. I designed streaming recovery and delivered the production upgrade that moved final-result persistence entirely to the backend.

Problem
Technicians need to switch investigations while an analysis runs. When they return, they need to see its progress or read the answer without submitting the same analysis again.
Decision
I separated execution from the HTTP stream, gave the backend responsibility for saving results, and built a client that reattaches to existing work.
Result
The backend saves the answer even if the browser misses the final update. Returning users can reattach to a live run or read the answer in conversation history.
Context
Sonatus - AI Technician
Period
2025–2026
My focus & role
Frontend architecture, streaming recovery, backend session services, production persistence upgrade, and administrative tooling.
Technology
React · TypeScript · SSE · FastAPI
From live output to a saved answerConcept model - synthetic data
Client connectionconnected

Provisional output A

Job staterunning

Generated output A

Persistence owner
Backend
Stored result
None

The stream is connected. The browser has provisional output A.

Failure scenarios
Event log

No events recorded.

FIG. 01 Generate output, navigate away, and return to see snapshot recovery. Finish generation and commit separately to see when the answer becomes available in history.

Context and ownership

Long-running work in a conversation interface

AI Technician presented analysis through a conversation interface, with progress, uploaded files, partial output, and completed responses. Users could switch conversations or navigate away before an answer finished. The product needed to distinguish an interrupted connection from an interrupted job.

I also built the administrative views and the platform endpoints that let operators inspect conversations and feedback. The conversation indicators show how I surfaced background activity in the chat list.

A follow-up in the conversation workspace

Adapted test screenshot
Conversation history beside a fault-code table, a follow-up question, and a suggested wheel-speed sensor check.View larger image (new tab)
FIG. 02 The selected test conversation keeps its code blocks, fault table, follow-up question and next action in one thread. The chat list gives the user a way back to other investigations. Cropped from an October 2026 export test with the company mark removed.

Streaming architecture

The backend runs and saves the analysis

I ran the analysis graph as an asynchronous Python task and kept accumulated progress and output on the server session. The HTTP response subscribes to that session. Closing the response releases its subscriber while the task can continue running and save its answer through the platform.

The browser sends user commands and renders provisional output. I implemented a streaming POST to start work and a separate GET to attach to an existing session. Both use server-sent events (SSE) to send diagnostic steps and partial answers to the conversation interface.

Who handles a run from start to saved answer?

BrowserSend commands, render progress, and load saved answers
Start, stop, and observe
Session API and event streamAccept requests and serve status and updates
Start work and relay progress
Backend taskExecute and assemble the final answer
Finalize through the platform
Durable storageKeep the final answer in conversation history
FIG. 03 The browser starts or stops work through the session API and receives snapshots and live updates over SSE. The backend task submits its result through the platform regardless of browser connectivity. The browser reads committed answers through the conversation API.

Two frames from a diagnostic replay

Frames from a test replay
In the first frame a signal check is pending. In the second it is complete, the first hypothesis is refuted, and another check reports an unavailable routing table.View larger image (new tab)
FIG. 04 Three seconds into the replay, the first signal check is still pending. At nine seconds the conversation shows its result and a failed lookup under the next hypothesis. The user can follow each diagnostic step while the agent is still working.

One session client for start, attach, status, and stop

I consolidated URL construction, request headers, event handling, and polling in a shared session client. It tracks the answer-end event so a premature stream close can enter recovery. The earlier transport retry could send another start POST, replace the analysis already in progress, and make the user wait for a new run.

Attach-first recovery

Recover live progress before starting new work

I designed reconnection to try attaching to the existing work first. A conversation groups the history, a user turn requests an analysis, and a run is the execution that produces its answer. The attach request uses the conversation ID to find the existing server session.

  1. Replace stale progress. Each attach attempt clears the client’s partial state. The server replays a snapshot with the available title, diagnostic steps, and answer so far. The client applies those events through the same reducer as ordinary streaming.
  2. Follow live events. The replay stream marks the switch from the snapshot to live events, which the server relays through a bounded queue for each subscriber. In the model above, a browser that left with AB replaces it with ABC on return, then adds D as it arrives.
  3. Read the saved answer. The client refreshes conversation history and renders the answer when it is available.

If the client cannot attach, it checks session status and refreshes conversation history within a bounded wait. When those checks find neither live work nor a saved answer, the conversation can show an interruption and keep the original prompt and attachment visible for a retry. Submitting the question again starts a new analysis.

Backend finalization

Confirm the save through conversation history

I made the backend responsible for saving the final answer through the platform. The write happens whether the original browser is still connected, another client has attached, or nobody is viewing the conversation. A user who misses the final update can reopen the conversation and retrieve the saved answer.

Generation can finish while the save is still pending. When a stream closes or a session reports itself inactive, a history read can confirm whether the answer is available to reopen and review.

Recover a saved answer after a missed notification

Concept model - synthetic data
  1. Generation finishesThe backend has the full answer. History has no saved result yet.
  2. The first save failsThe result remains uncommitted.
  3. Finalization succeedsThe answer is stored. The browser misses the completion event.
  4. The browser refreshes historyThe client retrieves the canonical answer from history.

The stream is connected. The browser has provisional output A.

FIG. 05 Step through a failed save followed by a successful commit. A history refresh retrieves the stored answer even when the last update is missed.

How I traced the lost follow-up answer

During an earlier iteration, letting both the browser and backend save produced duplicate replies. The next design gave the original browser the write while it appeared attached. The backend took over after detach.

I traced a lost follow-up to a title keepalive that held the stream open after the chat page had gone. The backend still expected that page to save. I limited the keepalive to turns still waiting for a title, then shipped backend-owned finalization so saving was independent of disconnect detection.

Failure and stop semantics

Distinguish leaving a chat from stopping an analysis

Leaving the page ends the browser’s subscription. An explicit Stop request goes through the session client to the backend. A stored stop notice records the user’s action. The backend determines the execution outcome, including when a Stop request arrives just as the analysis finishes.

I bounded status polling and paused it in hidden tabs so the interface could leave stale working states without polling indefinitely. Reattachment can restore progress while the backend still has the live session. An answer already saved in conversation history remains readable after that session is gone.

An interrupted request with a file attached

Adapted interface capture
A prompt with one attached file asks about diagnostic trouble codes. The response reports an interruption and directs the user to retry.View larger image (new tab)
FIG. 06 The original prompt and its attachment indicator remain visible when the client offers an explicit retry. This March 2026 capture shows the state before a retry. Cropped to the conversation turn with the company mark removed.

Administrative workflows

Give operators conversation and feedback context

I built administrative views for users, conversation lists, conversation detail, and feedback. The platform endpoints and response schemas supplied these views so support, product, and engineering teams could review records through an application interface.

I used paginated lists to help reviewers find a conversation, then loaded its messages and feedback in a detail view. A reviewer can read the original question and the assistant’s reply together with the feedback. User creation was a separate action.

Conversation and feedback review

Concept interface - synthetic data
Conversation
Demo A
Response excerpt
A synthetic response excerpt for reviewing feedback in conversation context.
Associated feedback
The response needs more context.
FIG. 07 Switch between the two sample conversations to see each response alongside the feedback it received.

The frontend used a feature gate and admin-role guard, while platform endpoints applied server-side access checks. Regular application records were scoped to users; a project grouped a user’s work rather than acting as an organization-wide tenant boundary. Keeping these concepts distinct was important when adding operational access.

Project artifacts

To tell users when a background answer was ready, I used saved replies in the sidebar’s unread check. A status probe could prompt a history refresh. The green dot appeared when the latest saved reply differed from the last one viewed in that browser and cleared when the user opened the conversation.

For the experience inside a conversation, see the multi-turn workspace, step-by-step response replay, and interrupted request with an attachment.

Activity in the conversation list

Paired test captures
The blue processing ring beside Engine check changes to a solid green unread indicator while Chat Jul 7 remains selected.View larger image (new tab)
FIG. 08 In the sidebar I implemented, Engine check shows a blue ring while work is running and a green dot when the result is ready to read. Chat Jul 7 stays selected in both captures. The August 2026 test screenshots are cropped to the same rows.

Delivery and verification

Users can leave an analysis running, come back to retained progress, or find the saved answer after completion. The same stored conversation is available to operators reviewing feedback in the administrative views I built.

I tested attachment to a live session, replay of accumulated events, and the platform endpoint that writes the answer. To verify the keepalive fix on a local stack, I switched chats during a follow-up, let the analysis finish, and reopened the conversation to find the full answer in history.

Based on my work at Sonatus. The interactive models use synthetic records. Project artifacts show original test-interface states.